[問題] 抓網頁UserWarning

看板Python作者 (mater)時間8年前 (2017/03/11 05:40), 編輯推噓2(208)
留言10則, 3人參與, 最新討論串1/1
import requests res = requests.get('http://money.cnn.com/2017/03/10/news/economy/february-j obs-report/index.html') from bs4 import BeautifulSoup soup = BeautifulSoup(res) print(soup.text) --------------------- 我在jupyter執行會出現 http://i.imgur.com/UIWbbPP.jpg
--------------------- 我是照著實例做,網址改掉而已。 我只知道應該要印出沒有tag的 內容 不懂問題在哪 我試著改這行 soup= BeautifulSoup((res), "html.parser") 改完後出現 http://i.imgur.com/Fptoc3L.jpg
但我看不懂 ------- 另外html.parser是什麼? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 211.72.106.139 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1489182057.A.4AB.html

03/11 06:32, , 1F
soup = BeautifulSoup(res) 改
03/11 06:32, 1F

03/11 06:32, , 2F
soup = BeautifulSoup(res.text)
03/11 06:32, 2F

03/11 06:33, , 3F
requests是回傳status code,要取得內容要用.text
03/11 06:33, 3F

03/11 06:34, , 4F
html.parser是新版BeautifulSoup要告訴他是用哪一種parser
03/11 06:34, 4F

03/11 06:34, , 5F
抱歉,requests不是回傳status code,我說錯了
03/11 06:34, 5F

03/11 06:35, , 6F
他是回傳Response,要取得內容要用.text
03/11 06:35, 6F

03/11 16:23, , 7F
請問requests 回傳 response要如何得知
03/11 16:23, 7F

03/11 16:24, , 8F
response是瀏覽器開發人員裡面的response嗎
03/11 16:24, 8F

03/11 22:23, , 9F
response 是指 requests 的 response object..
03/11 22:23, 9F

03/12 22:54, , 10F
response就是requests回傳的東西叫做response
03/12 22:54, 10F
文章代碼(AID): #1OmnrfIh (Python)
文章代碼(AID): #1OmnrfIh (Python)