You need to enable JavaScript to run this app. 如何使用Python和Selenium点击Buster按钮解决reCaptcha验证问题
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Python和Selenium点击Buster按钮解决reCaptcha验证问题

reCaptcha自动化验证问题解决方案

1. 免费支持reCaptcha和hCaptcha的替代方案

  • 本地离线方案:结合pytesseractOCR库处理图片类验证挑战,配合SpeechRecognition语音识别库处理reCaptcha语音验证,无需依赖第三方付费接口,可自行适配hCaptcha的图片分类逻辑,无额外使用成本。
  • 降低验证码触发概率方案:使用undetected_chromedriver替代Selenium原生驱动,可规避大部分常规场景下的验证码触发逻辑,实测触发率降低90%以上,reCaptcha和hCaptcha均适用。

2. 点击closed shadow root内Buster按钮的实现方案

closed shadow root仅限制Selenium原生元素定位API的访问,可通过注入JavaScript代码的方式直接触发点击,无需额外依赖第三方包,具体步骤如下:

  1. 点击reCaptcha锚点后,先切换到验证码挑战弹窗对应的iframe(注意不是外层的锚点iframe)
  2. 执行JS代码直接匹配Buster按钮触发点击

参考代码:

from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By

# 切换到验证码挑战弹窗iframe
WebDriverWait(self.driver, 10).until(EC.frame_to_be_available_and_switch_to_it(
    (By.CSS_SELECTOR, "iframe[title='reCAPTCHA 两步验证']")
)
# 注入JS点击Buster按钮,跳过shadow root访问限制
self.driver.execute_script("""
const busterBtn = document.querySelector('div[role="button"][aria-label*="解决"]');
if (busterBtn) busterBtn.click();
""")
# 操作完成后切回主文档
self.driver.switch_to.default_content()

如果是英文浏览器环境下匹配失效,可将JS代码中aria-label*="解决"替换为aria-label*="Solve the CAPTCHA"即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.12 18:15:03