如何解决如何使用 MSXML2 setTimeouts 防止超时错误?
我使用以下函数来检查 URL 是否在几秒钟内响应:
function testUrl(url)
Set xmlDOM = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlDOM.Open "GET",url,False
xmlDOM.setTimeouts 1000,1000,1000
testUrl=xmlDOM.Send
end function
if testUrl("http://khabarfoori.com/rss/mm") then
responsw.write "active"
else
response.write "inactive"
end if
我收到以下错误,而不是 "active" 或 "inactive":
> msxml6.dll error '80072ee2'
> The operation timed out
脚注: 上面经过测试的 URL 缓冲了大量文本,没有服务器错误。这是特殊情况,我需要更多代码来处理这种响应吗?
解决方法
也许这可以解决问题!
feed = "http://khabarfoori.com/rss/mm"
Set req = CreateObject("Msxml2.ServerXMLHTTP.6.0")
req.Open "GET",feed,False
req.Send
Set xml = CreateObject("Msxml2.DOMDocument")
xml.loadXml(req.responseText)
First_Title = xml.getElementsByTagName("channel/item/title")(0).Text
If Len(First_Title) <> 0 Then
MsgBox "active"
MsgBox First_Title
else
MsgBox"inactive"
End If
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。