Python Forum

Full Version: error when running headless selenium
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

I've made a script where it monitors the website of https://www.jdsports.nl with selenium. It works perfectly, until I run selenium headless. when I run selenium.title, it says 'acces denied', so I believe jdsports is denying me to acces the website. Does anyone know why this only happens when I run it headless and how to solve this?
thanks in advance!
Add site user-agent under options.
#--| Setup
options = Options()
options.add_argument("--window-size=1980,1020")
options.add_argument("--headless")
options.add_argument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36")
browser = webdriver.Chrome(executable_path=r'chromedriver.exe', options=options)
(Jan-31-2020, 10:33 PM)snippsat Wrote: [ -> ]options = Options()
options.add_argument("--window-size=1980,1020")
options.add_argument("--headless")
options.add_argument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36")
It works!:)
Thanks a lot for helping!!