如何使用Python插件reCaptcha客户端进行验证? [英] How to use Python plugin reCaptcha client for validation?
本文介绍了如何使用Python插件reCaptcha客户端进行验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想进行验证码验证.
我从 recaptcha网站上获得了密钥,并且已经成功地将公钥用于向网页加载挑战
I get the key from the recaptcha website and already succeed to put the public key to load the webpage with the challenge.
<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>
我下载了 reCaptcha Python插件,但是找不到有关如何用它.
I download the reCaptcha Python plugin but I can not find any documentation on how to use it.
有人对如何使用此Python插件有任何想法吗? recaptcha-client-1.0.4.tar.gz(md5)
Does anyone have any idea on how to use this Python plugin? recaptcha-client-1.0.4.tar.gz (md5)
推荐答案
这非常简单. 这是我正在使用的一个简单的Trac插件的示例:
It is quite straightforward. This is an example from a trivial trac plugin I'm using:
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
这篇关于如何使用Python插件reCaptcha客户端进行验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文