[英]Send token from 2Captcha API to solve Hcaptcha using Python Selenium Chromedriver
I am trying to solve the Hcaptcha page on a website protected by Cloudfare我正在尝试解决受 Cloudfare 保护的网站上的 Hcaptcha 页面
Website to access: https://carmanuals2.com/mazda/3-hatchback-2020-owner-s-manual-114463访问网站: https://carmanuals2.com/mazda/3-hatchback-2020-owner-s-manual-114463
I followed the instruction on Recatcha API and able to get token that are suppose to be placed in these two fields:我按照 Recatcha API 上的说明进行操作,并能够获取应该放置在这两个字段中的令牌:
<textarea id="g-recaptcha-response-0418tkobioj8" name="g-recaptcha-response" style="display: none;"></textarea>
<textarea id="h-captcha-response-0418tkobioj8" name="h-captcha-response" style="display: none;"></textarea>
API Documentation: https://2captcha.com/2captcha-api#solving_hcaptcha API 文档: https://2captcha.com/2captcha-api#solving_hcaptcha
Next step is to place the tokens on these two elements, However, I get a error as selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
下一步是将标记放在这两个元素上,但是,我收到一个错误,因为selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
Here is a snipppet of my code, where I try to place the token I received (captcha)这是我的代码片段,我尝试在其中放置收到的令牌(验证码)
sitekey = site["src"].split("=")[-1]
currenturl = driver.current_url
print (currenturl)
flag, captcha = solve_h_captcha(sitekey,currenturl)
username = driver.find_element_by_name('g-recaptcha-response')
username.send_keys(captcha)
time.sleep(2)
username = driver.find_element_by_name('h-captcha-response')
username.send_keys(captcha)
time.sleep(2)
# username.send_keys(captcha)
time.sleep(0.5)
Thanks a lot!!!!非常感谢!!!!
You probably need to do things like that from js:您可能需要从 js 执行类似的操作:
driver.execute_script("""
let [captcha] = arguments
document.querySelector('[name="h-captcha-response"]').innerHTML = captcha
document.querySelector('[name="g-captcha-response"]').innerHTML = captcha
""", captcha)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.