提问人:Howsikan 提问时间:11/16/2023 更新时间:11/19/2023 访问量:55
当验证码嵌入在 iframe 中时,如何使用 2Captcha 解决 LinkedIn 上的 Arkose FunCaptcha?
How do I solve an Arkose FunCaptcha on LinkedIn using 2Captcha when the CAPTCHA is embedded within an iframe?
问:
当我在Python/Selenium/Google Chrome脚本中通过2Captcha登录LinkedIn时,我正在尝试自动解决验证码。
为此,根据我之前提出的问题的答案,我在实例化我的 Web 驱动程序并为所有验证码启用自动求解时加载了 2Captcha Chrome 扩展程序的 CRX 文件。
但是,对于 LinkedIn,扩展程序无法检测到验证码,因为它位于网页的元素内。为了绕过这一点,我在 Python 脚本中添加了以下内容来检测和解决验证码:<iframe></iframe>
下面的脚本仍然无法检测并正确解决 FunCaptchas。我可以知道我可以做些什么来检测和解决里面的 LinkedIn 验证码吗?作为参考,附上了此验证码的图像和LinkedIn代码的片段(在我的下面)。<iframe></iframe>
我的 Python 代码:
try:
solver = TwoCaptcha('<API_KEY>')
captcha = driver.find_element(By.XPATH,
"//input[@name='captchaSiteKey']")
captcha_sitekey = captcha.get_attribute('value')
iframe = driver.find_element(By.XPATH, "//iframe")
iframe_source = iframe.get_attribute('src')
driver.switch_to.frame(iframe)
print(f'IFRAME Source: {iframe_source}')
print(f'CAPTCHA SiteKey: {captcha_sitekey}')
time.sleep(60)
result = solver.funcaptcha(sitekey=captcha_sitekey,
url=iframe_source)
for key in result:
print(f'{key}: {result[key]}')
print('We found and solved a CAPTCHA.')
driver.switch_to.default_content()
except Exception as e:
print(f'We could not solve the CAPTCHA because {str(e)}, '
f'{traceback.print_exc}')
(我没有在上面的代码块中编写它,但我正在导入 、 和 模块。traceback
2captcha-python
selenium
LinkedIn 在 CAPTCHA 页面上的 HTML:
<iframe class="" id="captcha-internal" src="./Security Verification _ LinkedIn_files/funCaptchaInternal.html"
frameborder="0" role="presentation" title="Captcha Challenge" height="290" width="302"></iframe>
<form method="post" class="hidden" id="captcha-challenge" action="https://www.linkedin.com/checkpoint/challenge/verify">
<input type="hidden" name="csrfToken" value="ajax:6505936439590984220"><input type="hidden" name="captchaSiteKey"
value="3117BF26-4762-4F5A-8ED9-A85E69209A46"><input type="hidden" name="challengeId"
value="AQFvUtZMWireaAAAAYvTP-Lq8KvlyrCr7xCgZlth6uf4UoJSq7UrP1-4bNpriHtPql8mOpZipQF3qa1vNAec2TT9aef2xMVB0Q"><input
type="hidden" name="language" value="en-US"><input type="hidden" name="displayTime"
value="AgFP_RD3wseHwQAAAYvTP-L3CpYje8Fh1rkGPsUfvp7WGYv0NvYEqR_gAaCDCew"><input type="hidden"
name="challengeType" value="AgFU-zncyoLVdAAAAYvTP-L66dj0drF5826EpedJld3sNEQ0b8diSPFWlBU"><input type="hidden"
name="challengeSource" value="AgGudd74ELMaKQAAAYvTP-L9K5-uGH1mPDpZy1yUGcdWEbCi3jtReJS_a-ufgicE"><input
type="hidden" name="requestSubmissionId"
value="AgF0RnGQ2BTi9QAAAYvTP-MA56TcJxjPSm3P71dof2-LrpBUMFM96V4_2m0pYDnLWnYMTPz9HIZ-TuCX35YFJgKBYom7WXc3eTGfrQ"><input
type="hidden" name="captchaUserResponseToken" value=""><input type="hidden" name="challengeData"
value="AgFlYfn-cheGuwAAAYvTP-LySUtucNcd5hW7d3PzwesMuCW97DRwpH_XItP5Ynt4E_dL4mZC18kF-5UGtjZ_l25oIZXIrhpW_qjH84--g65ZGktWQJloVkNrMiY3BrOTB1PuqhvwDnYhJj3o-jM54s5Ap1-0U7zDiU6lgAkA92Ez01S2-PBr15R44ZrVoFQPuRhOsUKQdSjREh4sPw6zjyx-9EYXEgPwnwWbCNjT8GpYr1GkobR0bQsa0RLjgkSOQ7KxV4iTVoYYHgt7UFssZQykI0PdVypaYVft3OoZTewLoz2Tg6GcIU58TItd4ulUP8gGj4NpKsQiMtqxf9mxs1hxkKtoOt29ZJ3RPa0Ge9z0bUYzjKChJNdORYHzSJcmnBPY4az1z3mw4hh7F0wbzZouuAb6yCwGtX_6sEnuaewCHBSaEbv-VwmNgDGk8-k_z-seh_2z2Q-s5gPanbEPBjhhseq9OBweFlXmSRf6h9KTlcizSGgBx7Yz9YBirkob2ukkxuU9yhmZ9911cUVMJ-ZaQU0jNOZW9PEX4ZLinEAWi5ei3X2bXfIc3lVhQ89RN-6t9G9uRFbOKOcrisiPt2MgDTBVni0QLkPcDOQyAahyxiTwJg8ksp3cPi16xZd4zr2VHiIT0Dm8CuI4GPImNdfMKjqZWuPjS7KC0_CtHvXa03cwfQAXSYGzDIX7obdutQ2XWT3JyXF4sz3o03bPIn2p0f7Aejd2yI6AH5krsacMqaVrSfLjSBq4xRBjLLg"><input
type="hidden" name="pageInstance"
value="urn:li:page:d_checkpoint_ch_captchaV2Challenge;KXxlvP5+SpygwcfBd+7rDg=="><input type="hidden"
name="challengeDetails"
value="AgFwKVDCcGn56wAAAYvTP-L1wL8sH9K8QYfqk4ydRmaR9VTdhiElPBT1pJ9zSFYaYZU7F6ulGXRJjDXGNCiOU_57wWr4ae19I_rc9qVKYlm5ggO43Yr8Q_AJX6TOv5s_fqbcAEakFbLgVvIu46NVK_TI1lwtIXay"><input
type="hidden" name="failureRedirectUri"
value="AgFg3MLPYMreRAAAAYvTP-MC_VIvK3O8g0pYH_FBHDR5q1XBY77au_DHDHrV1c78mXMKKhjrXIC-8vKyXQZuC7ashO7hSP0qRmwORfm-ECf1Tjuisx6n_Q"><input
type="hidden" name="signInLink" value="/checkpoint/lg/login?trk=homepage-basic_sign-in-submit"><input
type="hidden" name="joinNowLink" value="/signup/cold-join?source=homepage-basic_sign-in-submit"><input
type="hidden" name="_s" value="CONSUMER_LOGIN">
</form>
答:
0赞
r000bin
11/24/2023
#1
通过查看您的代码,我认为您需要切换到 iframe bevor 搜索验证码,如下所示:
iframe = driver.find_element(By.XPATH, "//iframe")
iframe_source = iframe.get_attribute('src')
driver.switch_to.frame(iframe)
captcha = driver.find_element(By.XPATH,
"//input[@name='captchaSiteKey']")
captcha_sitekey = captcha.get_attribute('value')
因为如果不切换到 iframe,selenium 就无法在其中找到元素。
如果这没有帮助:你的脚本在哪里失败?print 语句的输出是什么?
评论
0赞
Howsikan
11/24/2023
谢谢你的 r000bin。我很快就会运行它,如果它有效,我会给予赏金。
评论