Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom user-agent #109

Open
cp2587 opened this issue Mar 14, 2017 · 2 comments
Open

custom user-agent #109

cp2587 opened this issue Mar 14, 2017 · 2 comments

Comments

@cp2587
Copy link

cp2587 commented Mar 14, 2017

Hello,

We realized recently that altought we had set custom user-agent in headers params of splash/args when doing a request, this header was never used by splash afterward. For now the only working fix we found, is using 'splash:set_user_agent' directly into our lua scripts.

Are you aware of this bug ? Did we miss something ?

@kmike
Copy link
Member

kmike commented Mar 14, 2017

Hey @cp2587,

If you're using Lua scripts then headers are not handled automatically. From scrapy-splash readme (meta['splash']['dont_send_headers'] docs):

by default scrapy-splash passes request headers to Splash in 'headers' JSON POST field. For all render.xxx endpoints it means Scrapy header options are respected by default (http:https://splash.readthedocs.org/en/stable/api.html#arg-headers). In Lua scripts you can use headers argument of splash:go to apply the passed headers: splash:go{url, headers=splash.args.headers}.

Scroll to the last example in the https://github.com/scrapy-plugins/scrapy-splash#examples section - there is an example of how to make headers, cookies, etc. work with a Lua script.

@vionemc
Copy link

vionemc commented Feb 12, 2018

Does it work with Scrapy fake user agent?
https://github.com/alecxe/scrapy-fake-useragent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants