python - Selenium 卡在 "Checking your browser before accessing URL"

标签 python selenium

这是最近的问题,我想是三四天前开始的。它并没有与我自己的系统隔离,因为我也在远程服务器(Windows 10、Windows Server)上运行该软件。它也不是孤立于任何特定 URL,因为我现在无法通过任何具有此检查的 URL。

Title: "Just a moment..." "Checking your browser before accessing URL". "This process is automatic. Your browser will redirect to your requested content shortly." "Please allow up to 5 seconds..." "DDos Protection by Cloudflare" "Ray Id: xxxxxxxxxxxxxxxxxx"


  • 我尝试过不同的系统(均基于 Windows)
  • 我尝试了不同的驱动程序(壁虎和 Chrome )
  • 我尝试了不同的网址
  • from selenium import webdriver
    driver = webdriver.Chrome()
    driver.get('wwww.etherdelta.com')
    
    有谁知道我如何解决这个问题;或者是时候放下可怜的提米(程序)了吗?

    最佳答案

    我在 Firefox 上遇到了同样的问题。我能够通过切换到 Chrome 来解决它。
    示例代码:

    from selenium import webdriver
    url = "<WEBSITE>"
    options = webdriver.ChromeOptions()
    options.add_argument("--disable-blink-features=AutomationControlled")
    driver = webdriver.Chrome(options=options)
    driver.get(url)
    
    “--disable-blink-features=AutomationControlled”隐藏“navigator.webdriver”标志。
    Selenium webdriver: Modifying navigator.webdriver flag to prevent selenium detection
    编辑
    您还必须更改 chromedriver 的一些默认变量。
    perl 示例:
    perl -pi -e 's/cdc_/dog_/g' /path/to/chromedriver
    
    有关更多详细信息,请查看原始帖子。
    Can a website detect when you are using selenium with chromedriver?
    编辑 2
    Cloudflare 不断调整他们的算法,因此您可以尝试使用 undetected-chromedriver 而不是手动更改 chromedriver。
    undetected-chromedriver 是一个优化的 Selenium Chromedriver 补丁,它不会触发反机器人服务。它会自动下载驱动程序二进制文件并修补它。
    这是否可行取决于网站和当前的开发状态。 Cloudflare 似乎在跟踪 undetected-chromedriver 的发展。
    import undetected_chromedriver as uc
    url = "<WEBSITE>"
    driver= uc.Chrome()
    driver.get(url)
    

    关于python - Selenium 卡在 "Checking your browser before accessing URL",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64165726/

    相关文章:

    java - Selenium 点击div后面的链接

    java - 以自定义方式使用 Allure "Issue"注释(Selenium)

    java - : Expected condition failed: waiting for visibility of element located by(. 的 Selenium webdriver 问题。)

    python - 使用不带类型注释的 mypy 检测类型错误

    python - sklearn回归器: ValueError: Found arrays with inconsistent numbers of samples

    python - 简单的 Python IF 语句似乎不起作用

    python - 将文本从 Word 复制到 Python 不需要转义字符,为什么?

    c# - 使用 [FindsBy] 属性时将 IWebElements 作为 C#/Selenium 中的集合保存

    html - 有没有办法使用 Selenium/WebDriver 提取 html 评论?

    python - 检查类是否等于两个字符串之一