【问题标题】:Generate Google ReCaptcha from a local website从本地网站生成 Google ReCaptcha
【发布时间】:2017-03-29 09:29:08
【问题描述】:

我正在使用 python 请求模块抓取一个网站。该网站上的表格需要解决 ReCaptcha。我已经设法使用相同的站点密钥在本地网站上重新创建了这个 ReCaptcha。如果我在本地网站上解决 ReCaptcha 并获得“g-captcha-response”密钥,我可以将此密钥发布到原始网站吗?如果是这样,这是否可行,或者 Google 是否需要响应密钥以外的其他信息?


# I get the response key from my local website
CaptchaKey = response-key

# I post the response key on the original website
request.post(SubmitURL, data={'g-captcha-response': CaptchaKey}

这行得通吗?如果是,如何检查请求是否已成功发布?

【问题讨论】:

    标签: javascript python http-post python-requests recaptcha


    【解决方案1】:

    Google 验证码是不够的。您应该考虑使用 selenium+requests 的方法。

    第一部分:

    from selenium import webdriver
    
    driver = webdriver.Chrome("C:\chromedriver.exe")
    driver.get('desiredurl')
    #somesleep/waittill element/anything to wait till you solve the recaptcha
    cookies = driver.get_cookies()
    

    第 2 部分

    session = requests.Session()
    for cookie in cookies:
        session.cookies.set(cookie['name'], cookie['value'])
    
    payload = { 'username' : '',
                'password' : '',
                'g-captcha-response': CaptchaKey}
    
    
    login = session.post('DESIREDURL', data = payload)
    

    这个方法应该可以的

    【讨论】:

      猜你喜欢
      • 2011-03-29
      • 2019-04-06
      • 2023-01-20
      • 2020-09-16
      • 1970-01-01
      • 2023-03-29
      • 2019-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多