Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot change Scrapy settings

I want to download pages in Chinese, So i opened the command line and the python, and typed these code

from scrapy.conf import settings
settings.overrides['DEFAULT_REQUEST_HEADERS'] = {'Accept':'text/heml,application/xhtml+xml;q=0.9,*/*;q=0.8','Accept-Language':'ch',}

but it didn't work. The 'Accept-Language' remained 'en'. So i tried other settings, same thing happened. I just can't change the settings. Someone plz help me out, it drives me crazy! i spent 3 hours on it but got nothing. Thanks a lot!

like image 456
user1744946 Avatar asked Oct 14 '12 13:10

user1744946


People also ask

How do I change my Scrapy settings?

Designating the settings When you use Scrapy, you have to tell it which settings you're using. You can do this by using an environment variable, SCRAPY_SETTINGS_MODULE . The value of SCRAPY_SETTINGS_MODULE should be in Python path syntax, e.g. myproject.

How do I change user agent in Scrapy?

Open the configuration file of your Scrapy project using your preferred text editor. Search for the USER_AGENT option. Uncomment the line and set the value to the user-agent of your choice to permanently set the user agent for your Scrapy spider.

How do I stop being Scrapy?

In the latest version of Scrapy, available on GitHub, you can raise a CloseSpider exception to manually close a spider. It succeeds to force stop, but not fast enough. It still lets some Request running.

What is Concurrent_requests in Scrapy?

In the context of Scrapy, this means to send out “concurrent” requests instead of sending them one by one. In other words, this means that the Scrapy spider will send a X number of (simultaneous) requests to the web server at the same time.


1 Answers

is

settings.overrides['DEFAULT_REQUEST_HEADERS'] = {'Accept':'text/heml,application/xhtml+xml;q=0.9,*/*;q=0.8','Accept-Language':'ch',}

supposed to say text/heml or html?

like image 50
Chris Hawkes Avatar answered Sep 30 '22 13:09

Chris Hawkes