有时,我们想检测某个网址是否存在,或是一个URL是否存在,可以用下面这个简单代码实现,asp代码,简单方便
<%
url="http://www.cosowo.cn" '也可以使用特定文件如:http://cosowo.cn/logo.png
Function chku(murl)
on error resume next
Set xmlHttp = Server.CreateObject("Microsoft.XMLHTTP")
xmlHttp.open "GET",murl,false
xmlHttp.send
if xmlHttp.Status <> 200 then
chku=false
else
chku=true
end if
End Function
if chku(url) then
response.write(url&"链接正常")
else
response.write(url&"链接不存在")
end if
%>