You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Selenium通过reCAPTCHA后无响应问题求助

解决Selenium过reCAPTCHA后无响应的问题
  • 规避自动化特征检测
    多数网站会通过navigator.webdriver等属性识别Selenium环境,即便验证码通过,也会阻断后续逻辑。可通过Chrome配置隐藏这些特征:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    options = Options()
    options.add_argument("--disable-blink-features=AutomationControlled")
    options.add_experimental_option("excludeSwitches", ["enable-automation"])
    options.add_experimental_option('useAutomationExtension', False)
    
    driver = webdriver.Chrome(options=options)
    # 清除webdriver标识
    driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")
    
  • 模拟真实用户行为
    网站会通过操作节奏识别自动化,添加随机延迟、模拟鼠标交互:

    import time
    import random
    from selenium.webdriver.common.action_chains import ActionChains
    from selenium.webdriver.common.by import By
    
    # 点击按钮前模拟鼠标移动与延迟
    button = driver.find_element(By.XPATH, "//你的按钮XPath")
    ActionChains(driver).move_to_element(button).pause(random.uniform(0.5, 1.8)).click().perform()
    # 验证码通过后随机等待
    time.sleep(random.uniform(2.2, 4.5))
    
  • 使用undetected-chromedriver
    该库是修改后的ChromeDriver,专门规避反爬检测,比原生Selenium更难被识别:

    from undetected_chromedriver import Chrome
    
    driver = Chrome()
    # 后续操作与原生Selenium一致
    
  • 手动触发验证回调
    部分网站验证通过后需触发特定JS回调,可通过浏览器控制台查看验证成功后的网络请求或JS函数,用Selenium直接调用:

    # 假设验证成功后需调用window.verifySuccess()
    driver.execute_script("window.verifySuccess()")
    

内容的提问来源于stack exchange,提问作者vladik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 12:59:52