課程
/后端開發(fā)
/Python
/Python開發(fā)簡單爬蟲
什么情況啊
2016-11-19
源自:Python開發(fā)簡單爬蟲 6-4
正在回答
python3 缺省的編碼是unicode, 再在from_encoding設(shè)置為utf8, 會被忽視掉,代碼是從python2轉(zhuǎn)來的,去掉就可以了
俠客島的含笑 提問者
慕設(shè)計(jì)4984150 回復(fù) 俠客島的含笑 提問者
Nether2Observer 回復(fù) 慕設(shè)計(jì)4984150
zz77zz
慕婉清0239705
qq_夏夜_0 回復(fù) Nether2Observer
print('創(chuàng)建BS對象')soup = BeautifulSoup(html_doc, ? ? ? ? ? ? ? ? ? ? 'html.parser', ? ? ? ? ? ? ? ? ? ? # ?from_encoding='utf-8' ? ? ? ? ? ? ? ? ? ? )print('搜索節(jié)點(diǎn),獲取所有鏈接')links = soup.find_all('a')for link in links: ? ?print(link.name, link['href'], link.get_text())
舉報(bào)
本教程帶您解開python爬蟲這門神奇技術(shù)的面紗
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2016-11-20
python3 缺省的編碼是unicode, 再在from_encoding設(shè)置為utf8, 會被忽視掉,代碼是從python2轉(zhuǎn)來的,去掉就可以了
2016-11-26
print('創(chuàng)建BS對象')
soup = BeautifulSoup(html_doc,
? ? ? ? ? ? ? ? ? ? 'html.parser',
? ? ? ? ? ? ? ? ? ? # ?from_encoding='utf-8'
? ? ? ? ? ? ? ? ? ? )
print('搜索節(jié)點(diǎn),獲取所有鏈接')
links = soup.find_all('a')
for link in links:
? ?print(link.name, link['href'], link.get_text())