|
- Dim data, res, response() As Byte, Post_data, json As Object, i, orc_basic, orc_position
- Dim ii, Str
- data = "data:image/jpeg;base64," + Pic2Base64(selectfile(FileNameObj))
-
- orc_position = "https://aip.baidubce.com/rest/2.0/ocr/v1/accurate" '含位置信息
- orc_basic = "https://aip.baidubce.com/rest/2.0/ocr/v1/accurate_basic" '不含位置信息
- Post_data = "image=" + URLEncode(data) + "&type=" + URLEncode(orc_position) + "&detect_direction=false"
- With CreateObject("WinHttp.WinHttpRequest.5.1")
- .Open "post", "https://ai.baidu.com/aidemo", False
- .SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36"
- .SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- .SetRequestHeader "Referer", "https://ai.baidu.com/tech/ocr/general"
- .Send (Post_data)
- res = .responsetext
- 'Debug.Print res
- End With
- Set json = JsonConverter.ParseJson(res)
-
- Debug.Print res
- Stop
- Set data = json("data")("words_result")
复制代码
调用网上运行结果基本思路是什么,要掌握哪些知识点。,如调用VBA方法,运行百度Ocr,结果自动返回到单元格内。
|
|