當(dāng)前位置:
首頁(yè) >
html调用接口_搜狗ocr识别接口
發(fā)布時(shí)間:2023/12/9
42
豆豆
生活随笔
收集整理的這篇文章主要介紹了
html调用接口_搜狗ocr识别接口
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
詳細(xì)情況在代碼中說(shuō)明,如果不想自己使用TensorFlow,可使用下面接口
這是要識(shí)別的圖片:
最終識(shí)別的結(jié)果:
This is a lot of 12 point text to test theocr code and see if it works on all types
of file format.
The quick brown dog jumped over the
lazy fox.The quick brown dog jumped
over the lazy fox.The quick brown dog
jumped over the lazy fox.The quick
brown dog jumped over the lazy fox.
代碼塊:
# _*_ coding: utf-8 _*_ # Time: 2019.4.25 # Author: maxiaohui # Title 搜狗ocr識(shí)別接口 # 這個(gè)代碼涉及到抓包用的fiddlerimport requests # 庫(kù)文件def post_image():img = "one.png" # 圖片路徑files = {"pic_path": open(img, "rb")} # files # 類似data數(shù)據(jù)url = "http://pic.sogou.com/pic/upload_pic.jsp" # post的urlhtml = requests.post(url, files=files).text # requests 提交圖片print('html is ',html)get_content(html) # 結(jié)果是url就是圖片的url sougou 把本地圖片上傳到sougou服務(wù)器變成了他的圖片 調(diào)用解析函數(shù)把url傳入def get_content(keywords):url = "http://pic.sogou.com/pic/ocr/ocrOnline.jsp?query=" + keywords # keywords就是圖片url此方式為get請(qǐng)求ocrResult = requests.get(url).json() # 直接轉(zhuǎn)換為json格式contents = ocrResult['result'] # 類似字典 把result的value值取出來(lái) 是一個(gè)list然后里面很多json就是識(shí)別的文字for content in contents: # 遍歷所有結(jié)果print(content['content'].strip()) # strip去除空格 他返回的結(jié)果自帶一個(gè)換行post_image() # 調(diào)用上傳函數(shù)總結(jié)
以上是生活随笔為你收集整理的html调用接口_搜狗ocr识别接口的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: typescript vuex_Vue3
- 下一篇: 条码打印软件中如何设置条形码下面的字符间