【问题标题】:Send token from 2Captcha API to solve Hcaptcha using Python Selenium Chromedriver从 2Captcha API 发送令牌以使用 Python Selenium Chromedriver 解决 Hcaptcha
【发布时间】:2022-02-17 00:47:14
【问题描述】:

我正在尝试解决受 Cloudfare 保护的网站上的 Hcaptcha 页面

访问网站:https://carmanuals2.com/mazda/3-hatchback-2020-owner-s-manual-114463

我按照 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 文档:https://2captcha.com/2captcha-api#solving_hcaptcha

下一步是将标记放在这两个元素上,但是,我收到错误消息 selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

这是我的代码片段,我尝试在其中放置收到的令牌(验证码)

        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)

非常感谢!!!!

【问题讨论】:

    标签: python selenium selenium-chromedriver captcha


    【解决方案1】:

    你可能需要从 js 中做类似的事情:

    driver.execute_script("""
      let [captcha] = arguments
      document.querySelector('[name="h-captcha-response"]').innerHTML = captcha
      document.querySelector('[name="g-captcha-response"]').innerHTML = captcha
    """, captcha)
    

    【讨论】:

    • 使用 hcaptcha 不起作用。 Selenium 响应:消息:未知错误:无法设置属性 'innerHTML' of null
    猜你喜欢
    • 2021-10-22
    • 2020-11-24
    • 1970-01-01
    • 1970-01-01
    • 2020-02-03
    • 2022-11-11
    • 2022-11-02
    • 2021-04-10
    • 2020-05-12
    相关资源
    最近更新 更多