Scrapy overwrite json files instead of appending the file

后端 未结 6 1175
长情又很酷
长情又很酷 2020-12-28 10:57

Is there a way to overwrite the said file instead of appending it?

Example)

scrapy crawl myspider -o \"/path/to/json/my.json\" -t json    
scrapy cra         


        
6条回答
  •  伪装坚强ぢ
    2020-12-28 11:20

    Or you can add:

    import os
    
    if "filename.json" in os.listdir('..'):
            os.remove('../filename.json')
    

    at the beginning of your code.

    very easy.

提交回复
热议问题