1

Is it possible to access https://www.corsair.com/ with Selenium in Python without getting blocked by Corsair?

When I try to load the page in Selenium, it keeps giving me this error message: Error when loading the Corsair website with Selenium

What I tried to bypass it, is changing the user-agent to a random one, which didn't fix the issue.

This is my code:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from fake_useragent import UserAgent


options = webdriver.ChromeOptions()
options.add_argument("window-size=1400,600")
ua = UserAgent()
user_agent = ua.random
print(user_agent)
options.add_argument(f'user-agent={user_agent}')
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=options)

print('Loading Corsair Website ...')
driver.get("https://www.corsair.com/")
Andre Solbach
  • 95
  • 1
  • 1
  • 5
  • on my initial run, it worked, but after subsequent runs, their website somehow detects that it's automated software. Usually modifying the User-Agent helped me in those cases. – Gevorg Chobanyan Dec 25 '21 at 22:56
  • @GevorgChobanyan Yes when I first tried it, it worked as well, but after multiple tries, it didn't. Did you try using my code with the random User-Agent? Does it work for you? – Andre Solbach Dec 25 '21 at 23:26

1 Answers1

0

There are multiple ways to evade detection of Selenium automation and one of them is to use the following argument:

Code Block:

options = Options()
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
# options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument('--disable-blink-features=AutomationControlled')
s = Service('C:\\BrowserDrivers\\chromedriver.exe')
driver = webdriver.Chrome(service=s, options=options)
driver.get("https://www.corsair.com/")
driver.save_screenshot("image.png")

Screenshot:

image.png

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352