chineseocr_lite icon indicating copy to clipboard operation
chineseocr_lite copied to clipboard

Python 有接口版吗?

Open Zer0TheObserver opened this issue 3 years ago • 3 comments

python demo是网页版的, 有没有封装成模块的? 能够直接通过输入图片对象使用的? 然后返回一个json

Zer0TheObserver avatar Jun 25 '21 01:06 Zer0TheObserver

你可以在网页请求识别之前打开浏览器f12查看项目所请求的连接,比如这个项目,默认好像是http://ip:8089/api/tr-run/ ,你可以在python中用request去请求,会返回一个json。

k2361863478 avatar Aug 21 '21 03:08 k2361863478

我也需要这个。可是现在这个接口是multipart/form-data这种提交方式。我搞不定

fashen002 avatar Sep 21 '22 11:09 fashen002

def ocr(path): headers = { 'accept': 'application/json', # requests won't add a boundary if this header is set when you pass files= # 'Content-Type': 'multipart/form-data', }

files = {
    'file': open(path, 'rb'),
}

ip = '192.168.2.156'
port = '8089'
url = "http://" + ip + ":" + port + '/api/tr-run/'

response = requests.post(url, headers=headers, files=files)
return response.json()

luosaidage avatar Apr 10 '23 02:04 luosaidage