Scrapy: first delete the data in the export file and then write the contents

I have a scrapy command like this

scrapy crawl spidername -o items.json -t json

If I return this command twice, new data will be added to the end of the items.json file. However, I want all the old data in items.json to be deleted before the new data is saved. How can this be achieved?

+4
source share
1 answer

You can use,

scrapy crawl spidername -t json --nolog -o - > "items.json"

This way, you always get No Json file upload .

0
source

Source: https://habr.com/ru/post/1533040/


All Articles