Avoid Duplicate URL Crawling

后端 未结 3 708
灰色年华
灰色年华 2020-12-13 15:47

I coded a simple crawler. In the settings.py file, by referring to scrapy documentation, I used

DUPEFILTER_CLASS = \'scrapy.dupefilter.RFPDupeFilter\'


        
相关标签:
3条回答
  • 2020-12-13 16:30

    According to the documentation, DUPEFILTER_CLASS is already set to scrapy.dupefilter.RFPDupeFilter by default.

    RFPDupeFilter doesn't help if you stop the crawler - it only works while actual crawling, helps you to avoid scraping duplicate urls.

    It looks like you need to create your own, custom filter based on RFPDupeFilter, like it was done here: how to filter duplicate requests based on url in scrapy. If you want your filter to work between scrapy crawl sessions, you should keep the list of crawled urls somewhere in the database, or csv file.

    Hope that helps.

    0 讨论(0)
  • 2020-12-13 16:33

    I believe what you are looking for is "persistence support", to pause and resume crawls.

    To enable it you can do:

    scrapy crawl somespider -s JOBDIR=crawls/somespider-1
    

    You can read more about it here.

    0 讨论(0)
  • 2020-12-13 16:34

    you can rewrite Scheduler with Redis like scrapy-redis then you can avoid duplicate URL crawling when reruning your project.

    0 讨论(0)
提交回复
热议问题