1

我使用以下函数来检查 URL 是否在几秒钟内响应:

function testUrl(url)
    Set xmlDOM = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    xmlDOM.Open "GET", url, False
    xmlDOM.setTimeouts 1000,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

我得到以下错误,而不是“活跃”“不活跃” :

>     msxml6.dll error '80072ee2'
>     The operation timed out

脚注:上面测试的 URL 缓冲了大量文本,没有服务器错误。这是一个特例,我需要更多代码来处理这种响应吗?

4

1 回答 1

0

可能这可以解决问题!

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
于 2021-01-24T12:45:36.757 回答