使用python请求处理Google Recaptcha
我正在使用请求模块创建一个web机器人。我需要通过一个包含recaptcha的表单。我有一个本地网站,可以生成此recaptcha的g-captcha响应。我想知道g-captcha-response是否是通过recaptcha所需的唯一post参数。如果没有,我还需要发布哪些其他信息 这是我的密码:使用python请求处理Google Recaptcha,python,http,python-requests,recaptcha,Python,Http,Python Requests,Recaptcha,我正在使用请求模块创建一个web机器人。我需要通过一个包含recaptcha的表单。我有一个本地网站,可以生成此recaptcha的g-captcha响应。我想知道g-captcha-response是否是通过recaptcha所需的唯一post参数。如果没有,我还需要发布哪些其他信息 这是我的密码: CaptchaKey = # g-captcha-response from my local website Session = requests.Session() FormData = {
CaptchaKey = # g-captcha-response from my local website
Session = requests.Session()
FormData = {
'g-captcha-response': CaptchaKey
}
Session.post(SubmitURL, data=FormData)
这辆车在这里开得很好。在Python和请求中,您将看到以下最基本的内容
import requests, json
try:
content = requests.post(
'https://www.google.com/recaptcha/api/siteverify',
data={
'secret': RECAPTCHA_SECRET,
'response': captcha_response_from_form,
'remoteip': USER_IP_ADDRESS,
}
).content
except ConnectionError: # Handle fundamental connectivity issues
# Handle your error state
# Will throw ValueError if we can't parse Google's response
content = json.loads( content )
if not 'success' in content or not content['success']:
# The reCaptcha hasn't passed...