首页 发票识别 发票识别示例代码 发票识别[Python]

发票识别示例代码Python

作者: 阅读数:1303 上传时间:2022-09-23

发票识别

import requests
import base64 

appkey = 'your_appkey_here'
url = f"https://api.jisuapi.com/invoicerecognition2/recognize?appkey={appkey}"
with open('timg.jpg', 'rb') as f:
    pic = f.read()
post = {'pic': base64.b64encode(pic).decode('utf-8')
}

response = requests.post(url, data=post)
jsonarr = response.json()
if jsonarr['status'] != 0:
    print(jsonarr['msg'])
    exit()
result = jsonarr['result']
print(result['seller'], result['number'], result['code'], result['totalfee'], result['payee'], result['buyer'])
print(result)