ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
10.04k stars 1.16k forks source link

headless mode some param need to handle, but didn't handle it #938

Open lifefloating opened 1 year ago

lifefloating commented 1 year ago

i wrote some check rules to check ,headless mode if can pass bot check the result is navigator.userAgent navigator.plugins window.chrome setting has been checked out! Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/108.0.5359.94 Safari/537.36 [] None

image image

my code is:

import undetected_chromedriver as uc
import time
from selenium.webdriver.support.ui import WebDriverWait
from pyvirtualdisplay import Display

with Display(visible=False, size=(1366, 768), backend='xvfb') as _display:
    options = uc.ChromeOptions()
    # options.version_main = 91

    # options.use_subprocess = True
    options.add_argument('--headless')
    options.add_argument('--disable-gpu')
    options.add_argument('--no-sandbox')
    options.add_argument('--ignore-certificate-errors')
    options.add_argument('--disable-dev-shm-usage')
    options.add_argument('--disable-plugins-discovery') # disable plugins check
    options.add_argument("--start-maximized")
    options.add_argument("--disable-blink-features=AutomationControlled")
    options.add_argument('--no-first-run --no-service-autorun --password-store=basic')
    prefs = {
                "useAutomationExtension": False,
                "excludeSwitches": ["enable-automation"]
            }
    options.add_experimental_option("prefs", prefs)
    driver = uc.Chrome(options=options)
    driver.set_page_load_timeout(10)
    agent = driver.execute_script("return navigator.userAgent")
    plugin = driver.execute_script("return navigator.plugins")
    t = driver.execute_script("return window.chrome")
    print(agent)
    print(plugin)
    print(t)
    # driver.get('https://stargate.cam')
    driver.get('http://javabin.cn/bot/bot.html')
    # WebDriverWait(driver, 240,5).until(lambda x: x.title != "Just a moment...")
    time.sleep(10)
    driver.implicitly_wait(10)
    driver.refresh()
    cookies = driver.get_cookies()
    title = driver.title
    page_source = driver.page_source
    print(title)
    print(page_source)
    if not cookies:
        driver.implicitly_wait(10)

    print('111111111111')
    print(cookies)
lifefloating commented 1 year ago

@ultrafunkamsterdam