課程
/后端開發(fā)
/Python
/Python開發(fā)簡單爬蟲
代碼對比的跟老師的一樣了
2018-11-18
源自:Python開發(fā)簡單爬蟲 7-7
正在回答
下載器導(dǎo)入改成這個import urllib.request
我和你的錯誤一樣,去掉try塊之后,顯示html_parser中的get_text()有錯誤,
Traceback (most recent call last):? File "G:\eclipse-workspace(JAVAEE)\Python01\baike_spider\spider_main.py", line 41, in <module>??? obj_spider.craw(root_url)????? #啟動爬蟲? File "G:\eclipse-workspace(JAVAEE)\Python01\baike_spider\spider_main.py", line 23, in craw??? new_urls, new_data =self.parser.parse(new_url,html_cont)??? ? File "G:\eclipse-workspace(JAVAEE)\Python01\baike_spider\html_parser.py", line 40, in parse??? new_data = self._get_new_data(page_url,soup)? File "G:\eclipse-workspace(JAVAEE)\Python01\baike_spider\html_parser.py", line 27, in _get_new_data??? res_data['title'] =title_node.get_text()AttributeError: 'NoneType' object has no attribute 'get_text'
去掉try模塊,看一下錯誤,根據(jù)錯誤改一下
舉報
本教程帶您解開python爬蟲這門神奇技術(shù)的面紗
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2019-03-03
下載器導(dǎo)入改成這個import urllib.request
2018-12-06
我和你的錯誤一樣,去掉try塊之后,顯示html_parser中的get_text()有錯誤,
Traceback (most recent call last):
? File "G:\eclipse-workspace(JAVAEE)\Python01\baike_spider\spider_main.py", line 41, in <module>
??? obj_spider.craw(root_url)????? #啟動爬蟲
? File "G:\eclipse-workspace(JAVAEE)\Python01\baike_spider\spider_main.py", line 23, in craw
??? new_urls, new_data =self.parser.parse(new_url,html_cont)???
? File "G:\eclipse-workspace(JAVAEE)\Python01\baike_spider\html_parser.py", line 40, in parse
??? new_data = self._get_new_data(page_url,soup)
? File "G:\eclipse-workspace(JAVAEE)\Python01\baike_spider\html_parser.py", line 27, in _get_new_data
??? res_data['title'] =title_node.get_text()
AttributeError: 'NoneType' object has no attribute 'get_text'
2018-11-19
去掉try模塊,看一下錯誤,根據(jù)錯誤改一下