MsgBox(0,0,_XmlHttp("http://www.baidu.com"))
Func _XmlHttp($Url)
;說明:不用說了吧。
;作者:Sanhen
;網站:www.autoit.net.cn
;使用此函數,請保留此註釋。
Local $oHTTP,$sReturn
$oHTTP = ObjCreate("microsoft.xmlhttp")
$oHTTP.Open("get",$Url,false)
$oHTTP.Send()
$sReturn=BinaryToString($oHTTP.responseBody) ; BinaryToString 解決亂碼
Return $sReturn
EndFunc
以下為錯誤處理,當網址無效的時候,出現
Line-1:
Error: The requested action with this object has failed.
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $a=$oHTTP.Open("GET","http://kds.zj.com") $oHTTP.Send() $HTMLSource = $oHTTP.Responsetext MsgBox(0,'',$HTMLSource) Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription ) $_eventerror = 1 Endfunc |
全站熱搜
留言列表