[問題] beautifulsoup 抓網站資料

看板Python作者 (Take it easy)時間9年前 (2016/02/23 19:43), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/1
想要抓的資料是 http://store.hp.com/us/en/cat/Laptops Shop Now 所有連出去的連結 寫過其他的爬蟲程式,底下的方法都可以用,不知道為什麼這個網站抓不到想到的資料 homePage = requests.get("http://store.hp.com/us/en/cat/Laptops") homeSoup = BeautifulSoup(homePage.text.encode("utf-8"),"html.parser") for data in homeSoup.find_all('a',{"class":"details"}): print(data.get("href")) 麻煩大家幫忙解惑,謝謝 -- -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 153.150.182.222 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1456227786.A.8E4.html

02/23 20:44, , 1F
把"html.parser"的參數取消就可以了耶
02/23 20:44, 1F

02/23 21:10, , 2F
可以改用其他像"html5lib"會比較少出問題
02/23 21:10, 2F

02/23 21:19, , 3F
成功了! 感謝
02/23 21:19, 3F
文章代碼(AID): #1Mp4NAZa (Python)
文章代碼(AID): #1Mp4NAZa (Python)