問題

作者: oz5566 (阿康)   2018-12-07 16:28:30
https://xiang1023.blogspot.com/2017/09/python-1.html
這篇感覺有用

import requests
from bs4 import BeautifulSoup as bs
search_url = "https://www.104.com.tw/area/freshman/search?
這邊我還算董 應該
但這個
head = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36',
'Accept-Language':'zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4'}
res = requests.get(search_url, headers = head)
print(res.encoding)
res.encoding = 'utf8'
soup = bs(res.text)
下面這些是啥 阿 感覺是 瀏覽器的東西
作者: durantjosh (肚爛特‧喬許)   2018-12-07 16:29:00
就加個header騙server端吧
作者: oz5566 (阿康)   2018-12-07 16:29:00
照抄就可以ㄌ?
作者: durantjosh (肚爛特‧喬許)   2018-12-07 16:30:00
你還要看你爬的網站的編碼是啥啊
作者: oz5566 (阿康)   2018-12-07 16:30:00
神摸是編碼==怎摸看
作者: oz5566 (阿康)   2018-12-07 16:31:00
我ㄉ意思是 哪邊找https://i.imgur.com/dqN8tXP.png
作者: emptie ([ ])   2018-12-07 16:33:00
這年頭還有不是utf8的繁中網站嗎?ptt不算的話
作者: oz5566 (阿康)   2018-12-07 16:34:00
還有這些要打在打阿 我打那個SHELL 都錯誤https://i.imgur.com/oOIcyjs.png
作者: durantjosh (肚爛特‧喬許)   2018-12-07 16:34:00
我還真的遇過,不過那網站滿破爛的
作者: SuicideWorks (SuicideWorks)   2018-12-07 16:34:00
requests沒裝好吧
作者: durantjosh (肚爛特‧喬許)   2018-12-07 16:36:00
代表你還沒裝那個套件啊
作者: siscon (laisan)   2018-12-07 16:37:00
阿康竟然會寫程式 不是文組?
作者: SuicideWorks (SuicideWorks)   2018-12-07 16:39:00
http://puu.sh/CdSNz.py這學期某堂課專案寫來爬pttㄉ
作者: oz5566 (阿康)   2018-12-07 16:40:00
作者: emptie ([ ])   2018-12-07 16:42:00
文組就不能寫程式嗎
作者: oz5566 (阿康)   2018-12-07 16:42:00
奇怪 我照著打 怎摸安裝不了
作者: SuicideWorks (SuicideWorks)   2018-12-07 16:43:00
梅就ㄌ 你還是複製貼上
作者: surimodo (好吃棉花糖)   2018-12-07 16:46:00
pip3 install requestspython2跟python3好像安裝指令有差別

Links booklink

Contact Us: admin [ a t ] ucptt.com