Search code examples
pythoncsvscrapyscrapy-pipeline

Scrapy: how to access -o (output) argument written in terminal command


I'm making my own custom pipeline in scrapy project and you want access to -o argument so I can use it in naming my exported file in the new pipeline:

scrapy crawl hotels -o hotels_file.csv --loglevel=ERROR

I want access to hotels_file.csv for further use in my code

any help please ? thanks in advance :)


Solution

  • You can access from the spider by getting the value for 'FEED_URI' from the settings, like this:

    filename = self.settings['FEED_URI']}