如何使用Python Selenium Web驱动程序绕过reCAPTCHA

2024-06-06 09:24:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在编写一个Python网页抓取代码来抓取一个网站,这是该网站的链接https://publicrecordsaccess.fultoncountyga.gov/Portal/Home/Dashboard/29

我正在使用SeleniumWeb驱动程序来实现这一点,但我正在尝试以一种不需要手动单击并绕过reCAPTCHA的方式自动化代码。我在GitHub上在线查看了一些代码,通过使用Python解决音频挑战来绕过它。但当我这么做的时候,reCAPTCHA会感觉到,并说我在使用自动化软件。然后它会阻止我点击reCAPTCHA

我想知道是否有任何方法可以使用Python Selenium web驱动程序绕过reCAPTCHA

谢谢


Tags: 代码https网页home网站链接驱动程序手动
1条回答
网友
1楼 · 发布于 2024-06-06 09:24:10

您可以使用anti-captcha作为一个试用版的付费服务,您需要创建一个帐户来拥有API密钥

pip install python3-anticaptcha

RECAPTCHA V3的一个示例使用

from python3_anticaptcha import ReCaptchaV3TaskProxyless
# Enter the key to the AntiCaptcha service from your account. Anticaptcha service key.
ANTICAPTCHA_KEY = ""
# G-ReCaptcha - website google key.
SITE_KEY = '6LeuMjIUAAAAAODtAglF13UiJys0y05EjZugej6b'
# Page url.
PAGE_URL = 'https://some_link'
# The filter by which the employee with the required minimum score is selected.
# possible options - 0.3, 0.5, 0.7
MIN_SCORE=0.3
# The value of the `action` parameter, which is passed by the recaptcha widget to google.
PAGE_ACTION='login'
# Get string for solve captcha, and other info.
user_answer = ReCaptchaV3TaskProxyless.ReCaptchaV3TaskProxyless(anticaptcha_key = ANTICAPTCHA_KEY)\
                .captcha_handler(websiteURL=PAGE_URL,
                                 websiteKey=SITE_KEY,
                                 minScore=MIN_SCORE,
                                 pageAction=PAGE_ACTION
                                )

print(user_answer)

More info Here

另见anti-captcha API documentation

相关问题 更多 >