防水墙验证码发送请求的必要参数
params = {
"aid": self.aid,
"AppSecretKey": self.AppSecretKey,
"Ticket": ticket,
"Randstr": randstr,
"UserIP": self.UserIP
}
url = "https://ssl.captcha.qq.com/ticket/verify"
方法一 使用urlopen发送
params = urlencode(params)
f = urlopen("%s?%s" % (self.url, params))
content = f.read()
res = json.loads(content)
if int(res.get("response")) != 1:
return {"errno": status.CODE_CAPTCHA_ERROR, "errmsg": message.captcaht_no_match}
方法二 使用requests发送
f = requests.get(self.url,params)
dic = f.json()
if dic.get('response') != '1':
return {"errno": status.CODE_CAPTCHA_ERROR, "errmsg": message.captcaht_no_match}