Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道您可以scrapy shell -s USER_AGENT='custom user agent' 'http://www.example.com'更改USER_AGENT,但是如何添加请求标头?
scrapy shell -s USER_AGENT='custom user agent' 'http://www.example.com'
USER_AGENT
目前没有直接在 cli 上添加标题的方法,但您可以执行以下操作:
$ scrapy shell ... ... >>> from scrapy import Request >>> req = Request('yoururl.com', headers={"header1":"value1"}) >>> fetch(req)
这将使用该新请求更新当前 shell 信息。