使用ddddocr识别验证码
import urllib3
import ddddocr
code_url = "http://www.xxxx.com/code.php"
headers = "{你的header是内容}"
http = urllib3.PoolManager() resq = http.request('GET', code_url,headers=headers) img_content_bytes = resq.data with open ('/root/yzm.png',mode='w+b') as fi: fi.write(img_content_bytes)
#保存为/root/yzm.png图片
#使用ddddocr识别刚才保存的图片
ocr = ddddocr.DdddOcr()
with open('/root/yzm.png', 'rb') as f:
img_bytes = f.read()
ver_code = ocr.classification(img_bytes)
print(ver_code)
本文来自博客园,作者:忙碌在路上,转载请注明原文链接:https://www.cnblogs.com/netsa/p/17053156.html