In scrapy tutorials said that for saving output to csv or any other format we should use this command:
scrapy crawl spider -o result.csv -t csv
in general we can use this command:
scrapy crawl my_spider -o file_name.extension -t extension
but I used this command without -t and there is no problem:
scrapy crawl spider -o result.csv
My question is what is role of -t?
Whenever you are not sure, look into the source code.
According to the crawl.py source code, if you don't specify the format explicitly, Scrapy would detect it - the extension of the file name would be used as a format:
if not opts.output_format:
opts.output_format = os.path.splitext(opts.output)[1].replace(".", "")
In your case csv would be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With