html调用接口_搜狗ocr识别接口
生活随笔
收集整理的這篇文章主要介紹了
html调用接口_搜狗ocr识别接口
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
詳細情況在代碼中說明,如果不想自己使用TensorFlow,可使用下面接口
這是要識別的圖片:
最終識別的結(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識別接口 # 這個代碼涉及到抓包用的fiddlerimport requests # 庫文件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請求ocrResult = requests.get(url).json() # 直接轉(zhuǎn)換為json格式contents = ocrResult['result'] # 類似字典 把result的value值取出來 是一個list然后里面很多json就是識別的文字for content in contents: # 遍歷所有結(jié)果print(content['content'].strip()) # strip去除空格 他返回的結(jié)果自帶一個換行post_image() # 調(diào)用上傳函數(shù)總結(jié)
以上是生活随笔為你收集整理的html调用接口_搜狗ocr识别接口的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: typescript vuex_Vue3
- 下一篇: python爬取b站弹幕_爬取B站弹幕并