Checking links

H

Harag

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
 
D

dlbjr

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=impersonate}").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
 
H

Harag

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top