标签:ima base bsp use 代码 safari base64 .text web
#!/usr/bin/env python # encoding: utf-8 #@author: 东哥加油 #@file: autologin.py #@time: 2018/12/19 10:14 import requests import json import jsonpath import base64 import pytesseract import re from PIL import Image class autologin: def __init__(self): print(‘‘) def login(self,quanshang): if quanshang == ‘10gcw‘: self.login_dfcf() else: print(‘接口未开发‘) def login_dfcf(self): sess = requests.session() headers = { ‘Origin‘:‘http://www.10gcw.com‘, ‘User-Agent‘: ‘Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36‘, ‘Origin‘:‘http://www.10gcw.com‘, ‘Referer‘: ‘http://www.10gcw.com/reg‘, ‘Accept‘: ‘application/json, text/plain, */*‘, } url_yzm = ‘http://api.99bccp.com/member/v1/code‘ response = sess.get(url_yzm,headers=headers) html = response.text jsonobj = json.loads(html) clientId = jsonpath.jsonpath(jsonobj, ‘$..clientId‘) code = jsonpath.jsonpath(jsonobj, ‘$..code‘) img = base64.b64decode(code[0]) file = open(‘yzm.png‘, ‘wb‘) file.write(img) file.close() image = Image.open(‘yzm.png‘) img = image.convert("RGBA") str = pytesseract.image_to_string(img) nstr = re.findall(‘\d+‘, str) str_1 = ‘‘ for i in nstr: str_1 = str_1 + i d_yzm = int(str_1) print(d_yzm) url = ‘http://api.99bccp.com/member/v1/register/login‘ headers = { ‘Origin‘:‘http://www.10gcw.com‘, ‘User-Agent‘: ‘Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36‘, ‘clientId‘:clientId[0], ‘Referer‘:‘http://www.10gcw.com/reg‘, ‘Accept‘:‘application/json, text/plain, */*‘, ‘Content-Type‘:‘application/json;charset=UTF-8‘, ‘Accept-Language‘:‘zh-CN,zh;q=0.9‘ } name=‘wurong903‘ password=‘dfgx1234‘ data = {"name":name,"password":password,"payPassword":"2745","code":d_yzm,"promoteCode":"","bankName":""} data1 = json.dumps(data) response1 = sess.post(url,data=data1,headers=headers) print(response1.text) if __name__ == ‘__main__‘: al = autologin() al.login(‘10gcw‘)
抓包使用的工具 telerik fiddler
目前这段代码,验证码的准确率有待提高,10次大概有1次识别不了。1.需要增加机器学习 2.这段代码改一下,可以登录券商
标签:ima base bsp use 代码 safari base64 .text web
原文地址:https://www.cnblogs.com/52shaidan/p/10159155.html