如果条件为true(例如scrap_item_id == predefine_value),则有机会停止爬网。我的问题与Scrapy类似-如何识别已经被抓取的网址,但是我想在发现最后一个被抓取的物品后“强迫”我的抓取spider停止爬行。
在GitHub上可用的最新版本的Scrapy中,你可以引发CloseSpider异常以手动关闭蜘蛛。
在0.14版本说明文档中提到了文档:“添加了CloseSpider异常以手动关闭蜘蛛(r2691)”
根据文档的示例:
def parse_page(self, response): if 'Bandwidth exceeded' in response.body: raise CloseSpider('bandwidth_exceeded')