gpt4 book ai didi

python - 如何使用 Selenium 和 Python 绕过 Google 验证码?

转载 作者:行者123 更新时间:2023-12-03 10:09:43 48 4
gpt4 key购买 nike

如何使用 Selenium 和 Python 绕过 Google 验证码?
当我试图抓取一些东西时,谷歌会给我一个验证码。我可以使用 Selenium Python 绕过 Google 验证码吗?
例如,它是 Google reCAPTCHA .您可以通过此链接查看此验证码:https://www.google.com/recaptcha/api2/demo

最佳答案

开始使用 Selenium的 Python 客户端,您应该避免解决/绕过 Google CAPTCHA .

Selenium
Selenium自动化浏览器。现在,你想用这种能力实现什么完全取决于个人,但主要是为了通过浏览器客户端自动化 Web 应用程序以进行测试,当然不限于此。

验证码
另一方面,CAPTCHA (首字母缩写词是......完全自动化的公共(public)图灵测试,以区分计算机和人类......)是一种用于计算的挑战 - 响应测试,以确定用户是否是人类。
因此,Selenium 和 CAPTCHA 服务于两个完全不同的目的,理想情况下不应该用于完成任何相互关联的任务。
话虽如此,reCAPTCHA可以轻松检测网络流量并将您的程序识别为 Selenium 驱动 机器人 .

通用解决方案
但是,有一些通用方法可以避免在网络抓取时被检测到:

  • 网站可以确定您的脚本/程序的首要属性是通过您的。显示器尺寸 .所以推荐不是 使用常规 Viewport .
  • 如果您需要向网站发送多个请求,请继续更改 用户代理 在每个请求上。在这里你可以找到关于 Way to change Google Chrome user agent in Selenium? 的详细讨论。
  • 要模拟类人行为,您可能需要减慢脚本执行速度,甚至超过 WebDriverWait。和 expected_conditions诱导time.sleep(secs) .在这里你可以找到关于 How to sleep Selenium WebDriver in Python for milliseconds 的详细讨论。

  • 这个用例
    然而,在几个用例中,我们能够与 reCAPTCHA 进行交互。使用 Selenium,您可以在以下讨论中找到更多详细信息:
  • How to click on the reCAPTCHA using Selenium and Java
  • CSS selector for reCAPTCHA checkbok using Selenium and VBA Excel
  • Find the reCAPTCHA element and click on it — Python + Selenium

  • 引用
    您可以在以下位置找到一些相关的讨论:
  • How can I make a Selenium script undetectable using GeckoDriver and Firefox through Python?
  • Is there a version of Selenium WebDriver that is not detectable?

  • tl;博士
  • How does reCAPTCHA 3 know I'm using Selenium/chromedriver?
  • 关于python - 如何使用 Selenium 和 Python 绕过 Google 验证码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58872451/

    48 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com