第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

AttributeError: 'UrlManager' object has no attribute 'new_urls'

Traceback (most recent call last):

? File "H:\python\qthnluwei\src\baike\spider_main.py", line 33, in <module>

? ? obj_Spider.craw(root_url)

? File "H:\python\qthnluwei\src\baike\spider_main.py", line 13, in craw

? ? self.urls.add_new_url (root_url)

? File "H:\python\qthnluwei\src\baike\url_manager.py", line 11, in add_new_url

? ? if url not in self .new_urls and url not in self.old_urls:

AttributeError: 'UrlManager' object has no attribute 'new_urls'

根據(jù)老師講的運行了程序,但報錯。沒有對new_urls定義?請問如何進行處理。

正在回答

2 回答

class UrlManager(object):
??? def __init__(self):
?????? self.new_urls=set()
?????? self.old_urls=set()

??? def add_new_url(self,url):
??????? if url is None:
??????????? return
??????? if url not in self.new_urls and url not in self.old_urls:
??????????? self.new_urls.add(url)

??? def add_new_urls(self,urls):
???????? if urls is None or len(urls)==0:
???????????? return

???????? for url in urls:
???????????? self.add_new_url(url)

??? def has_new_url(self):
??????? return len(self.new_urls)!=0

??? def get_new_url(self):
??????? new_url=self.new_urls.pop()
??????? self.old_urls.add(new_url)
??????? return new_url



0 回復 有任何疑惑可以回復我~
#1

慕粉3851000 提問者

非常感謝!
2017-02-23 回復 有任何疑惑可以回復我~

沒看懂 這段代碼有變化嗎?

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Python開發(fā)簡單爬蟲
  • 參與學習       227603    人
  • 解答問題       1282    個

本教程帶您解開python爬蟲這門神奇技術(shù)的面紗

進入課程

AttributeError: 'UrlManager' object has no attribute 'new_urls'

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號