Is there a way to trigger a method in a Spider class just before it terminates?
I can terminate the spider myself, like this:
class MySpider(CrawlS
if you have many spiders and want to do something before each of them closing, maybe it will be convenient to add statscollector in your project.
in settings:
STATS_CLASS = 'scraper.stats.MyStatsCollector'
and collector:
from scrapy.statscollectors import StatsCollector
class MyStatsCollector(StatsCollector):
def _persist_stats(self, stats, spider):
do something here