Set headers for scrapy shell request

698 views
Skip to first unread message

Twirl

unread,
May 4, 2016, 8:49:45 AM5/4/16
to scrapy-users
scrapy shell -s USER_AGENT='custom user agent' 'http://www.example.com' works for setting the USER_AGENT but how do you set the headers?

Thanks

Valdir Stumm Junior

unread,
May 5, 2016, 3:25:31 PM5/5/16
to scrapy...@googlegroups.com
Hey, I'm not sure how you could do it through the command line. But you can do it inside the scrapy shell:

>>> req = scrapy.Request('http://example.com', headers={'Referer': 'bla bla'})
>>> fetch(req)

On Tue, May 3, 2016 at 2:33 PM, Twirl <gust...@gmail.com> wrote:
scrapy shell -s USER_AGENT='custom user agent' 'http://www.example.com' works for setting the USER_AGENT but how do you set the headers?

Thanks

--
You received this message because you are subscribed to the Google Groups "scrapy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scrapy-users...@googlegroups.com.
To post to this group, send email to scrapy...@googlegroups.com.
Visit this group at https://groups.google.com/group/scrapy-users.
For more options, visit https://groups.google.com/d/optout.



--
Scrapinghub

Valdir Stumm Junior 
Developer Evangelist, Scrapinghub 

Skypestummjr
TwitterGithub
TwitterLinkedInGithub

We turn web content into structured data. Lead maintainers of Scrapy.

Reply all
Reply to author
Forward
0 new messages