花钱解决,目前还不会写识别验证码的代码,写过但是没有生效
所以干脆直接购买了图鉴的服务,一分钱调用一次
# 调用图鉴接口识别验证码 http://www.ttshitu.com/
def base64_api(uname, pwd, img, typeid):
with open(img, 'rb') as f:
base64_data = base64.b64encode(f.read())
b64 = base64_data.decode()
data = {"username": uname, "password": pwd, "typeid": typeid, "image": b64}
result = json.loads(requests.post("http://api.ttshitu.com/predict", json=data).text)
if result['success']:
return result["data"]["result"]
else:
#return result["message"]
print(f'图鉴接口调用失败,{result["message"]}')
return ""