reCAPTCHA总是返回错误的captcha sol

reCAPTCHA always returns incorrect-captcha-sol

本文关键字:captcha sol 错误 返回 reCAPTCHA      更新时间:2023-09-26

我试图在我的Python web应用程序中验证reCAPTCHA,但我总是收到incorrect-captcha-sol错误,尽管响应是正确的。这是验证代码:

data = {
    'privatekey': config.registry.settings['captcha_private_key'],
    'remoteip': ip,
    'challenge': challenge,
    'response': response,
}
request = urllib2.Request('http://www.google.com/recaptcha/api/verify',
                          urllib.urlencode(data))
response = urllib2.urlopen(request)
if response.readline() != 'true':
    log.error('Captcha validation error, error_code=%s' % (response.readline()))
    raise httpexceptions.HTTPUnauthorized()

为了获得挑战和响应值,我使用get_challenge()get_response() javascript函数,然后通过AJAX发送值。

解决了这个问题。QUnit自动化的javascript测试似乎以某种方式与catpcha交互,从而产生了incorrect-captcha-sol代码。