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)

可随意转载,欢迎署名!