Skip to content
Advertisement

Being able to change the settings while running scrapy from a script

I want to run scrapy from a single script and I want to get all settings from settings.py but I would like to be able to change some of them:

JavaScript

I wasn’t able to use this. I tried the following:

JavaScript

but it didn’t work.

Note: I’m using the latest version of scrapy.

Advertisement

Answer

So in order to override some settings, one way would be overriding/setting custom_settings, the spider’s static variable, in our script.

so I imported the spider’s class and then override the custom_setting:

JavaScript

So this is the whole script:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement