我尝试按照http://doc.scrapy.org/en/0.22/topics/jobs.html中的描述使用 spider.state ,但出现错误
MyCrawlSpider has no attribute 'state'
我尝试在CrawlSpider 派生类的init () 函数中使用它。这可能是问题吗?
class MyCrawlSpider(CrawlSpider):
crawl_start = datetime.utcnow().isoformat()
def __init__(self, *args, **kwargs):
super(MyCrawlSpider, self).__init__(*args, **kwargs)
if self.state.get('crawl_start'):
crawl_start = self.state.get('crawl_start')
else:
self.state["crawl_start"] = crawl_start
我的目标是让 crawl_start 属性始终位于我的爬虫首先启动的 isoformat 日期时间字符串上,与 x 何时恢复开始无关