I have a working scrapy 2.1.0 project where I write data to a json file:
def open_spider(self, spider):
self.file = open('data/'+ datetime.datetime.now().strftime ("%Y%m%d") + '_' + spider.name + '.json', 'wb')
self.exporter = JsonItemExporter(self.file)
Now I want to deploy it to scrapyd, but since the data folder does not exist under /tmp it will lead to the following error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/scrapy/crawler.py", line 91, in crawl
yield self.engine.open_spider(self.spider, start_requests)
FileNotFoundError: [Errno 2] No such file or directory: 'data/20200518_rieger.json'
How can the above code be rewriten in order to work with scrapyd?