scrapy crawl test -o test123.csv
How can I call the Output filename from code i.e I would like to use the filename inputed in terminal in spider_closed
function
@classmethod
def from_crawler(cls, crawler, *args, **kwargs):
spider = super(MySpider, cls).from_crawler(crawler, *args, **kwargs)
crawler.signals.connect(spider.spider_closed, signal=scrapy.signals.spider_closed)
def spider_closed(self):
#read test123.csv (whatever the filename is)
You can use
self.settings.attributes["FEED_URI"].value
in your spider to get output file name.