課程
/后端開(kāi)發(fā)
/Python
/Python開(kāi)發(fā)簡(jiǎn)單爬蟲(chóng)
為啥第一個(gè)后面的就只有一個(gè)failed
2016-01-01
源自:Python開(kāi)發(fā)簡(jiǎn)單爬蟲(chóng)
正在回答
剛看到一個(gè)最近的相似的問(wèn)題-_-||
有可能你的try-except中間的print 'craw %d : %s' %(count, new_url)到except那一塊某個(gè)地方使用的代碼打錯(cuò)了而不是self.urls.has_new_url()==0導(dǎo)致的錯(cuò)誤,python的百科里面是有別的鏈接的,你可以試著把try-except去掉,讓錯(cuò)誤直接顯示出來(lái)
中間這一塊指的是:
html_cont=self.downloader.download(new_url)new_urls,new_data=self.parser.parse(new_url,html_cont)self.urls.add_new_urls(new_urls)self.outputer.collect_data(new_data)if count==1000: ? ?breakcount=count+1根據(jù)錯(cuò)誤位置設(shè)置print 相應(yīng)的變量查看錯(cuò)誤原因.
比如說(shuō)我一開(kāi)始就是url_manager.py的UrlManager類(lèi)的add_new_urls方法打錯(cuò)了,導(dǎo)致的錯(cuò)誤
你這樣年輕 提問(wèn)者
舉報(bào)
本教程帶您解開(kāi)python爬蟲(chóng)這門(mén)神奇技術(shù)的面紗
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-02-16
剛看到一個(gè)最近的相似的問(wèn)題-_-||
有可能你的try-except中間的print 'craw %d : %s' %(count, new_url)到except那一塊某個(gè)地方使用的代碼打錯(cuò)了而不是self.urls.has_new_url()==0導(dǎo)致的錯(cuò)誤,python的百科里面是有別的鏈接的,你可以試著把try-except去掉,讓錯(cuò)誤直接顯示出來(lái)
中間這一塊指的是:
html_cont=self.downloader.download(new_url)
new_urls,new_data=self.parser.parse(new_url,html_cont)
self.urls.add_new_urls(new_urls)
self.outputer.collect_data(new_data)
if count==1000:
? ?break
count=count+1
根據(jù)錯(cuò)誤位置設(shè)置print 相應(yīng)的變量查看錯(cuò)誤原因.
比如說(shuō)我一開(kāi)始就是url_manager.py的UrlManager類(lèi)的add_new_urls方法打錯(cuò)了,導(dǎo)致的錯(cuò)誤