$oHTTP.Send() $oHTTP^ ?? 【已解决】
本帖最后由 redapple2008 于 2020-9-1 13:46 编辑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$oHTTP.Send()$oHTTP^ ??这一句总是出错,怎么解决?#include <GUIConstantsEX.au3>
AccessURL()
Exit
Func AccessURL()
Local $sURL = "http://www.what21.com"
; 创建一个简单的输入界面
GUICreate("内容窗口", 640, 480);
Local $idGUIEdit = GUICtrlCreateEdit("HTTP 调用展示 HTML:" & @CRLF, 10, 10, 600, 400);
; 显示 GUI
GUISetState()
; 执行HTTP GET 调用
Local $oHttpObj = ObjCreate("winhttp.winhttprequest.5.1");
; 这里也可以用 GET 或者 POST调用
$oHttpObj.open("POST", $sURL);
$oHttpObj.send();
Local $sHTMLSource = $oHttpObj.Responsetext;
; 将内容填入控件中
GUICtrlSetData($idGUIEdit, "HTML地址 " & $sURL & " 内容:" & @CRLF & @CRLF & StringAddCR($sHTMLSource), "append")
; 等待 知道关闭框口
Local $iMsg
While 1
$iMsg = GUIGetMsg()
If $iMsg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()
EndFunc
就这也出错。
$oHttpObj.open("POST", $sURL);查资料说这句要大写,我也是大写啊! microsoft.xmlhttp不会出错。 网站启用了TLS协议,win10以下系统需安装补丁包 redapple2008 发表于 2020-9-1 11:18
$oHttpObj.open("POST", $sURL);查资料说这句要大写,我也是大写啊!
都能运行
+>12:45:03 启动 AutoIt3Wrapper v15.920.938.0 SciTE v3.6.0.0键盘:E0230804操作系统:WIN_7/Service Pack 1CPU:X64系统架构:X64语言环境:0804
+> SciTE 目录 => D:\AutoIt3\SciTEAutoIt3Wrapper 用户目录 => C:\Users\chzj589\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE 用户目录 => C:\Users\chzj589\AppData\Local\AutoIt v3\SciTE
>运行 AU3Check (3.3.14.2) 检查代码.参数: D:\AutoIt3au3 文件: D:\AU3调试\3D图表\硬盘读取INITXT\oHTTP.Send.au3
+>12:45:03 AU3Check 语法检查结束.rc: 0
>运行:D:\AutoIt3\autoit3_x64.exe(3.3.14.2), 脚本: D:\AutoIt3\autoit3_x64.exe "D:\AU3调试\3D图表\硬盘读取INITXT\oHTTP.Send.au3"
--> 点击 Ctrl+Alt+Break 重新启动, 或 Ctrl+Break 停止脚本执行
chzj589 发表于 2020-9-1 12:46
都能运行
+>12:45:03 启动 AutoIt3Wrapper v15.920.938.0 SciTE v3.6.0.0键盘:E0230804操作系统:WIN ...
十分感谢,可能是我的系统版本问题,我的是win10,64位。 问题应该找到了,我上网用代理上网,所以这里出错了。不能直接出去。
页:
[1]