问题描述
我使用以下函数来检查 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