找回密码
 加入
搜索
查看: 1476|回复: 4

[AU3基础] 一个POST请求错误 不知道如何拦截这个错误做出操作[已解决]

[复制链接]
发表于 2020-6-23 18:12:05 | 显示全部楼层 |阅读模式
本帖最后由 .Simba 于 2020-6-29 09:30 编辑

在请求链接地址错误的情况下,脚本会直接报错退出,如何处理这个错误呢?

提示内容如下:
The requested action with this object has failed.:
$oHTTP.WaitForResponse()
$oHTTP^ ERROR
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.Option(4) = 13056 ;忽略错误标志
        $oHTTP.SetTimeOuts(1000, 1000, 1000, 1000) ;设置超时时间
        $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


发表于 2020-6-27 20:24:19 | 显示全部楼层
帮助文档里的COM错误参考一下


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2020-6-29 09:29:41 | 显示全部楼层
heroxianf 发表于 2020-6-27 20:24
帮助文档里的COM错误参考一下

问题解决,XX
发表于 2020-6-29 10:33:13 | 显示全部楼层

6天前就该解决,饭要喂到嘴里。
 楼主| 发表于 2020-6-29 13:02:57 | 显示全部楼层
afan 发表于 2020-6-29 10:33
6天前就该解决,饭要喂到嘴里。

不好意思,回家过端午节了。(*❦ω❦)
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-14 01:14 , Processed in 0.080699 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表