scrapy不過濾重復url


今天在爬取一個朝鮮網站:http://www.rodong.rep.kp/cn/index.php?strPageID=SF01_01_02&iMenuID=2時,發現它會重定向多次,又回到原url,如果scrapy過濾重復url,則無法爬取。

所以,查資料發現:可以重復爬取,而且設置比較簡單。

資料如下:

https://blog.csdn.net/huyoo/article/details/75570668

實際代碼如下:

def parse(self, response):
meta = response.meta
===================================================================================
meta["website"] = "http://www.rodong.rep.kp/ko/"
meta['area'] = 'xj_rodong_rep_kp'

start_url_list = [
# "http://www.rodong.rep.kp/cn/index.php?strPageID=SF01_01_02&iMenuID=3",
# "http://www.rodong.rep.kp/cn/index.php?strPageID=SF01_01_02&iMenuID=5",
# "http://www.rodong.rep.kp/cn/index.php?strPageID=SF01_01_02&iMenuID=6",
# "http://www.rodong.rep.kp/cn/index.php?strPageID=SF01_01_02&iMenuID=7",
# "http://www.rodong.rep.kp/cn/index.php?strPageID=SF01_01_02&iMenuID=1&iSubMenuID=1",
"http://www.rodong.rep.kp/cn/index.php?strPageID=SF01_01_02&iMenuID=2"
]
for url in start_url_list:
yield Request(url, meta=meta, callback=self.parse_list, dont_filter=True)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM