469,323 Members | 1,583 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

Checking links

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
2 1578
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
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.

Similar topics

2 posts views Thread by leegold2 | last post: by
3 posts views Thread by Phil Lamey | last post: by
4 posts views Thread by Tom Esker | last post: by
2 posts views Thread by clarket | last post: by
6 posts views Thread by RoSsIaCrIiLoIA | last post: by
8 posts views Thread by Steve | last post: by
1 post views Thread by rpupkin77 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.