I am using a scrapy CrawlSpider
and defined a twisted reactor to control my crawler. During the tests I crawled a news site collecting more than several GBs of data
In scrapy
there is the class scrapy.extensions.closespider.CloseSpider
.
You can define the variables CLOSESPIDER_TIMEOUT
, CLOSESPIDER_ITEMCOUNT
, CLOSESPIDER_PAGECOUNT
and CLOSESPIDER_ERRORCOUNT
.
The spider closes automatically when the criteria is met: http://doc.scrapy.org/en/latest/topics/extensions.html#module-scrapy.extensions.closespider