我使用以下函数来检查 RSS url 是否健康,然后使用它:
function testUrl(url)
testUrl=0
Set o = CreateObject("MSXML2.XMLHTTP")
on error resume next
o.open "GET", url, false
o.send
if o.Status = 200 then testUrl = 1
on error goto 0
set o=nothing
end function
但是,当目标 URL 在短时间内没有响应时,我会收到超时错误。因此,如果没有成功响应,我想在此 Q/A中使用以下函数在5 秒后终止请求,但我不知道将 asp_Wait(5) 放在哪里以及如何在 5 秒后取消请求?我应该把 asp_Wait 放在 or 同步之后o.send
吗o.send
?
Function asp_Wait(nMilliseconds)
Dim oShell
Set oShell= Server.CreateObject("WScript.Shell")
Call oShell.run("ping 1.1.1.1 -n 1 -w " & nMilliseconds,1,TRUE)
End Function