0

I'm running into an issue being able to automate (website (clickhere))

It appears that the site is protected in someway for chromedriver. When I visit the website normally I have no problem, but when selenium attempts to automate the site, the url redirects to some other home page.

Here is my sample code:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

chrome_options = Options()
#chrome_options.add_argument("--headless")

EXE_PATH = 'chromedriver.exe'
driver = webdriver.Chrome(executable_path=EXE_PATH)#, options=chrome_options)
driver.get(SEE URL ABOVE)
time.sleep(5)
print(driver.current_url)
driver.quit()

Please use the link in the hyperlinked text. I removed it from my code here.

Wondering if anyone has run into similar issues with websites picking up that the browser is being automated with selenium, and if there is any possible way around this. If not, maybe you have a suggestion that you could share to tackle from another angle.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
dataviews
  • 2,466
  • 7
  • 31
  • 64

1 Answers1

1

A bit more about your usecase and why you felt ...that the site is protected... would have helped us to further analyze the issue. However through Selenium to access the site you can use the following solution:

  • Code Block:

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    
    options = webdriver.ChromeOptions()
    options.add_argument("start-maximized")
    #options.add_argument("--headless")
    options.add_experimental_option("excludeSwitches", ["enable-automation"])
    options.add_experimental_option('useAutomationExtension', False)
    driver = webdriver.Chrome(options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
    driver.get("https://publicindex.sccourts.org/horry/publicindex/")
    WebDriverWait(driver, 10).until(EC.title_contains("Index"))
    print(driver.current_url)
    driver.quit()
    
  • Console Output:

    https://publicindex.sccourts.org/horry/publicindex/
    

Outro

You can find a couple of relevant discussions in:

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