使用硒时是否可以尽可能地模仿真人

is it possible to emulate the real person as same as possible when using selenium

提问人:Dolphin 提问时间:11/17/2023 最后编辑:Dolphin 更新时间:11/17/2023 访问量:22

问:

我正在使用 selenium 进行一些自动测试,最近我们的安全团队添加了 cloudflare 旋转门,使我的自动测试过程失败,除了人工验证外,一切正常:

enter image description here

我已将 selenium 更改为未检测到 google 驱动程序似乎对此不起作用。是否有可能恢复人工验证过程?我应该怎么做才能恢复它?这是我现在正在使用的 Python 代码:

from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
import undetected_chromedriver as uc
from apps.visa.browser.visa_book import VisaBook
import urllib3
import shutil
import os

urllib3.disable_warnings()

if __name__ == '__main__':
    home_dir = os.path.expanduser("~")
    src_file = os.path.join(home_dir, "chrome/base/chromedriver-mac-x64.zip")
    dist_file = os.path.join(home_dir, "chrome/chromedriver/chromedriver-mac-x64.zip")
    shutil.copy(src_file, dist_file)
    driver_service = Service(ChromeDriverManager().install())
    options = uc.ChromeOptions()
    options.add_argument("--auto-open-devtools-for-tabs")
    options.add_argument('--disable-blink-features=AutomationControlled')
    driver = uc.Chrome(
        options=options,
        headless=False,
        use_subprocess=False,
        chrome_driver_zip_path=dist_file,
        driver_service=driver_service)
    wait: WebDriverWait = WebDriverWait(driver, 600)
    driver.get("https://example.com/login")
    visa_book = VisaBook()
    visa_book.login(wait, driver)
python-3.x selenium-webdriver cloudflare

评论


答: 暂无答案