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

How to add Custom Headers to helium ? #93

Open
firaki12345-cmd opened this issue Sep 7, 2022 · 2 comments
Open

How to add Custom Headers to helium ? #93

firaki12345-cmd opened this issue Sep 7, 2022 · 2 comments

Comments

@firaki12345-cmd
Copy link

Hi so i have the followinng code, i can change the user-agent jsut fine, but how to add additional header options ?

from selenium.webdriver import FirefoxOptions
from helium import*


useragent = "Mozilla/5.0 (X11; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0"

options = FirefoxOptions()

options.set_preference("general.useragent.override",useragent)


s = start_firefox("https://www.instagram.com", headless=False, options=options,)

time.sleep(15)

kill_browser()

i want to add the following full headers.. How can I do that ? Thanks

headers = {"Accept":	"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
"Accept-Encoding"	: "gzip, deflate, br",
"Accept-Language"	: "en-GB,en;q=0.5",
"Connection"	: "keep-alive",
"Host"	: "data.similarweb.com",
"Sec-Fetch-Dest"	: "document",
"Sec-Fetch-Mode"	: "navigate",
"Sec-Fetch-Site"	: "none",
"Sec-Fetch-User"	: "?1",
"Upgrade-Insecure-Requests"	: "1",
"User-Agent"	: "Mozilla/5.0 (X11; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0"}
@rahulmr
Copy link

rahulmr commented Sep 7, 2022

Why do you need to add headers like this? Are you trying to do API testing?

@firaki12345-cmd
Copy link
Author

Why do you need to add headers like this? Are you trying to do API testing?

Hi thanks for the reply.

Some websites block if proper headers are not there. I am web scraping many retail websites.

I was web scraping just fine.. but could not open Nordstrom.

So that's why want to ask how to add custom headers to the script.

Nordstrom opens fine while regular browsing.. but not with helium/selenium

Thanks

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

No branches or pull requests

2 participants