I am trying to record the end time of my crawler. When scrapy finishes it dumps the scrapy stats to the log. I have been trying to use a pipeline to record these stats by using the close_spider method.
I have the stats as a field of my pipeline (self.stats).
def close_spider(self,spider):
record_crawl_stats(self.stats)
The problem is that the 'finish_time' isn't available when this is called.
I am trying to find a way of getting a hold of the same stats as the ones that are dumped at the end.
(I could just get the datetime.now() for the finish time, but there are some other stats that I want access too that also are not available, such as the finish reason, and I believe number of items created)
Through research I found some answers to similar questions, were the scraper handles the spider closing. However, the code in both of these is not compatible with the current version of scrapy for various reasons.
https://stackoverflow.com/a/13799984/5078308
https://stackoverflow.com/a/11246025/5078308
Does anyone have any idea how to get similar functionality updated for the latest version or a different way of solving this?