How to stop scrapy spider after certain number of requests?

后端 未结 5 644
情书的邮戳
情书的邮戳 2021-02-04 20:01

I am developing an simple scraper to get 9 gag posts and its images but due to some technical difficulties iam unable to stop the scraper and it keeps on scraping

5条回答
  •  故里飘歌
    2021-02-04 21:01

    There's a built-in setting CLOSESPIDER_PAGECOUNT that can be passed via command-line -s argument or changed in settings: scrapy crawl -s CLOSESPIDER_PAGECOUNT=100

    One small caveat is that if you've enabled caching, it will count cache hits as page counts as well.

提交回复
热议问题