Python Forum
error when running headless selenium
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
error when running headless selenium
#1
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!
Reply
#2
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)
Reply
#3
(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!!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Selenium weird error julio2000 0 1,647 Feb-23-2020, 01:24 PM
Last Post: julio2000
  Selenium webdriver error WiPi 4 11,987 Feb-09-2020, 11:38 AM
Last Post: WiPi
  Headless Chrome: How to login into a webpage? amandacstr 1 4,234 Feb-06-2020, 02:19 AM
Last Post: metulburr
  Error after a few minutes of running julio2000 10 5,296 Feb-05-2020, 11:05 PM
Last Post: julio2000
  Error clicking button with selenium julio2000 4 5,252 Jan-06-2020, 10:59 AM
Last Post: julio2000
  Running flask run produces error. Charles1 1 4,028 Oct-04-2019, 10:38 PM
Last Post: snippsat
  Selenium error with ebdriver (geckodriver) Martinelli 4 4,665 Sep-24-2019, 01:40 AM
Last Post: Martinelli
  Python Selenium .click() Loads Error - Works Manually.- Events not Triggered NSearch 24 11,532 Aug-14-2019, 02:23 PM
Last Post: NSearch
  Unable to access javaScript generated data with selenium and headless FireFox. pjn4 0 2,502 Aug-04-2019, 11:10 AM
Last Post: pjn4
  Error when trying to use Selenium ejected 1 5,144 Mar-26-2019, 04:53 AM
Last Post: ejected

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020