我想把我的代码放到帖子里,但是放不进去,我就以回复的形式发出来了。#RequireAdmin
#include <String.au3>
#include <base64.au3>
#include<bug.au3>
$file = FileOpen(@ScriptDir"\nihao.bmp")
$filestring = FileRead($file)
$basestring = _Base64Encode($filestring)
MsgBox(0, 0, $basestring & @CRLF)
$return = _XmlHttp("https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=24.121752deff4d80a5854a872aa7d8e86a.2592000.1588397555.282335-10725585", "image=" & $basestring, "", "UTF-8", "")
MsgBox(0, 0, $return & @CRLF)
Func _XmlHttp($httpurl, $data = "", $type = "", $charset = "", $ContentType = "")
$oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
If $type = "" Or $type = "POST" Then
$stype = "POST"
Else
$stype = "GET"
EndIf
$oHTTP.Open($stype, $httpurl, True)
$oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134")
$oHTTP.SetRequestHeader("Accept-Language", "zh-CN,zh;q=0.8")
$oHTTP.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
$oHTTP.SetRequestHeader("Connection", "Close")
If $ContentType = "json" Then
$ContentTypes = "application/json"
ElseIf $ContentType = "xml" Then
$ContentTypes = "text/xml"
ElseIf $ContentType = "formdata" Then
$ContentTypes = "multipart/form-data"
ElseIf $ContentType = "" Then
$ContentTypes = "application/x-www-form-urlencoded"
EndIf
If $charset = "" Or $charset = "UTF-8" Then
$charsets = "UTF-8"
Else
$charsets = "GBK"
EndIf
$oHTTP.SetRequestHeader("Content-Type:", $ContentTypes & '; charset=' & $charsets)
$oHTTP.SetRequestHeader("Cache-Control", "no-cache")
$oHTTP.Send($data)
$oHTTP.WaitForResponse()
$oReturnWebS = BinaryToString($oHTTP.ResponseBody, 4)
Return $oReturnWebS
EndFunc ;==>_XmlHttp
|