如何使用Python插件reCaptcha客户端进行验证?

Hoa*_*ham 16 python validation plugins captcha recaptcha

我想进行验证码验证.

我从recaptcha网站获得密钥,并且已经成功地将公钥加载到挑战的网页.

<script type="text/javascript"
   src="http://api.recaptcha.net/challenge?k=<your_public_key>">
</script>

<noscript>
   <iframe src="http://api.recaptcha.net/noscript?k=<your_public_key>"
       height="300" width="500" frameborder="0"></iframe><br>
   <textarea name="recaptcha_challenge_field" rows="3" cols="40">
   </textarea>
   <input type="hidden" name="recaptcha_response_field" 
       value="manual_challenge">
</noscript>
Run Code Online (Sandbox Code Playgroud)

我下载了reCaptcha Python插件,但是我找不到任何关于如何使用它的文档.

有没有人知道如何使用这个Python插件?recaptcha-client-1.0.4.tar.gz(md5)

abb*_*bot 25

这很简单.这是我正在使用的一个简单的trac插件的示例:

from recaptcha.client import captcha

if req.method == 'POST':
    response = captcha.submit(
        req.args['recaptcha_challenge_field'],
        req.args['recaptcha_response_field'],
        self.private_key,
        req.remote_addr,
        )
    if not response.is_valid:
        say_captcha_is_invalid()
    else:
        do_something_useful()
else:
    data['recaptcha_javascript'] = captcha.displayhtml(self.public_key)
    data['recaptcha_theme'] = self.theme
    return 'recaptchaticket.html', data, n
Run Code Online (Sandbox Code Playgroud)

  • 您应该将其安装为常规python包.如果你是所有这些东西的新手,我建议你阅读python的一些入门课程.您可以尝试http://diveintopython.org/toc/index.html或http://docs.python.org/tutorial/index.html作为一个很好的起点. (2认同)