一個(gè)好用的驗(yàn)證碼識(shí)別接口(附代碼)
開發(fā)一些自動(dòng)化腳本程序時(shí),很可能會(huì)遇到一些圖形驗(yàn)證碼需要識(shí)別,使用過百度,ddddocr,但是都不滿意,百度之前有免費(fèi)額度,現(xiàn)在是收費(fèi)的,ddddocr 只能識(shí)別不區(qū)分大小寫的驗(yàn)證碼,除非你能自己訓(xùn)練。
但是這個(gè) ocr 接口,支持英文字母或數(shù)字的驗(yàn)證碼識(shí)別,能區(qū)分英文大小寫,使用起來感覺還可以,就分享給大家使用。
- 接口地址:
https://api.dazheng.site/ocr/:apikey/ - 接口文檔:
https://api.dazheng.site點(diǎn)擊閱讀原文跳轉(zhuǎn)
示例代碼:
curl:
curl -X POST -H "Content-Type: multipart/form-data" -F "file=@/path/to/your/image.jpg" https://api.dazheng.site/ocr/your_apikey/
Python:
import requests
headers = {
# requests won't add a boundary if this header is set when you pass files=
# 'Content-Type': 'multipart/form-data',
}
files = {
'file': open('/path/to/your/image.jpg', 'rb'),
}
response = requests.post('https://api.dazheng.site/ocr/你的apikey/', headers=headers, files=files)
print(response.json())
成功響應(yīng) 狀態(tài)碼:200 OK 返回內(nèi)容:
{"message":"ok","remaining_calls":991,"text":"mm69nn"}
錯(cuò)誤響應(yīng) 狀態(tài)碼:400 返回內(nèi)容:
{"error":"Your API key is not valid."}
更多其他語(yǔ)言代碼及細(xì)節(jié),可以閱讀 API 文檔 https://api.dazheng.site/ocr.html[1]
圖片數(shù)據(jù)處理
上傳的圖片的內(nèi)容(二進(jìn)制流)會(huì)直接用于識(shí)別,識(shí)別完成即銷毀,不會(huì)被保存至磁盤。
最后
感謝閱讀,如果有幫助,歡迎點(diǎn)贊、關(guān)注、轉(zhuǎn)發(fā)。
參考資料
[1]https://api.dazheng.site/ocr.html: https://api.dazheng.site/ocr.html
評(píng)論
圖片
表情
