分析
其实这个网站基本没有用到过什么逆向,就是简单的图片base64加密 然后把连接变成2进制存成文件 然后用ocr去识别即可
!! 注意 在获取图片连接 和对列表页发起请求时一定要用一个请求,也就是用一个session 不然就会验证失败。
代码如下
import ddddocr
import requests
from jsonpath import jsonpath
import base64
url = "xxxxx"
data = {
"width": "150",
"height": "40",
"codeNum": "4",
"interferenceLine": '4',
"codeGuid": "",
}
html = requests.post(url,data=data).json()
image=jsonpath(html,"$..custom")[0]
json_image=eval(image)
code = json_image['imgCode']
verificationCodeGuid = json_image['verificationCodeGuid']
data = code.split(',')[1]
image_data = base64.b64decode(data)
with open('code.png', 'wb') as f:
f.write(image_data)
with open('code.png','rb') as fp:
image = fp.read()
# 利用ocr识别图片
ocr = ddddocr.DdddOcr()
result = ocr.classification(image)
print(result)
print(verificationCodeGuid)
# params={
#
# "cmd": "RightInfoList",
# "vname": "/linyiweb",
# "cate": "001001",
# "pageSize": "10",
# "pageIndex": "101",
# "ssqy": "",
# "xmbh": "",
# "ggmc": "",
# "cglb": "",
# "imgguid": "ae3e7c7d-1f8e-4a83-aec0-f2d2aecc411f",
# "yzm": "2W2H",
# }
# html = requests.get("xxxxx",params=params).json()
标签:code,image,JS,json,某省,服务平台,import,ocr,data
From: https://www.cnblogs.com/zichliang/p/16634356.html