By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,837 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

Checking links

P: n/a
Hi all

win 2k pro
sql server 2k
asp - vbscript
I got the below code from somewhere ages ago. I have a list of links
on my site that link to other sites but I want to check if the link is
a valid link automatically and if it fails after x checks (checks
every 7 days) then to mark the link as a possible broken link

the below seems to take ages to process and was wondering if there is
a better way to do the below.

thanks for any help & tips.

Al
Set xmlhttp = CreateObject("MSXML2.XMLHTTP")
on error resume next
xmlhttp.open "get", sURL, False
xmlhttp.send
if err.number = 0 then
iStatus = xmlhttp.Status
else
'error might be "DNS error"
iStatus = 404
end if
on error goto 0
Set xmlhttp = nothing

' if status =200 then it is a VALID url.
if iStatus = 200 then
' valid link
' update db here
else
' invalid link.
' update db
end if

Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
UseWMI and impersonate a ping on the url.
This will clarify if the site is up or down without sending the page itself.

Function GetPing(strTarget)

GetPing = False

On Error resume Next

set oPing = GetObject("winmgmts:{impersonationLevel=impersonat e}").ExecQuery
("select * from Win32_PingStatus where address = '" & strTarget & "'")

For Each o In oPing

sResp = o.StatusCode

Next

If Len(sResp) > 0 Then

if sResp = 0 Then

GetPing = True

End If

End If

set oPing = Nothing

End Function

-dlbjr

invariable unerring alien
Jul 19 '05 #2

P: n/a
Thanks for the code below.

It quicker than my previous code but its still taking about 4-5
seconds per link... but I think thats the nature of the net these
days.

thanks again.
Al

On Sat, 13 Sep 2003 13:19:23 -0500, "dlbjr" <do******@do.u> wrote:
UseWMI and impersonate a ping on the url.
This will clarify if the site is up or down without sending the page itself.

Function GetPing(strTarget)

GetPing = False

On Error resume Next

set oPing = GetObject("winmgmts:{impersonationLevel=impersonat e}").ExecQuery
("select * from Win32_PingStatus where address = '" & strTarget & "'")

For Each o In oPing

sResp = o.StatusCode

Next

If Len(sResp) > 0 Then

if sResp = 0 Then

GetPing = True

End If

End If

set oPing = Nothing

End Function

-dlbjr

invariable unerring alien


Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.