2
我嘗試使用spider.state在http://doc.scrapy.org/en/0.22/topics/jobs.html描述,但我得到的錯誤CrawlSpider派生類對象達斯沒有屬性「狀態」
MyCrawlSpider has no attribute 'state'
我嘗試在INIT(用它)的功能一個CrawlSpider派生類。這可能是問題嗎?
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繼續在那裏開始