Link to home
Start Free TrialLog in
Avatar of huang_juxiang
huang_juxiang

asked on

asp script to check and report broken links

hi,

i need to create a asp script to check and report broken links.
i have a page whereby it contains 1000 urls from a database and then its lame to check every single one of them manually....so i need to create a page to check for any broken links and then stored the url into a text file
Avatar of markhoy
markhoy
Flag of United Kingdom of Great Britain and Northern Ireland image

see www.hotscripts.com or www.planet-source-code.com and use one of their scripts.
Avatar of huang_juxiang
huang_juxiang

ASKER

i been there...they dun have asp script...they only have perl or php...i dunno how to run them
The only way I can think of doing it is to have a page that iterates through the links in the database and uses something like ASPTear to go to the page and search for known strings such as "HTTP 404 - File not found".

ASPTear can be found at: http://www.alphasierrapapa.com/IisDev/Components/AspTear/

It's free, but you need to be able to install components on your server.

Hope this helps.
ASKER CERTIFIED SOLUTION
Avatar of markhoy
markhoy
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i have a sample script but the thing is that i don't tink that the script is working coz i have a broken link within the database but they still return postive to me (postive = working, negative = not working), however when i try the url http:// with nothing...it returns me negative....
can any1 pls help me to look at this script and highlight to me how can i solve this prob....
example of my broken link: http://www.nyp.edu.sg/as/studdev/c_sd07.htm

==========================================================
the script: url.asp
==========================================================
<% @Language="VBScript" %>
<% Option Explicit
Response.Buffer = True
On Error Resume Next
'==========================================================================='
' This ASP (Active Server Pages) program does the following:
' 1) Reads URLs from a database;
' 2) Uses "XMLHTTP" to validate each prepending "http://"; if necessary;
' 3) Lists each URL with a "+" (found) or "-" (not found) prefix.

Const cASP = "URL.asp"
Const cMDB = "Links.mdb"

Dim strDSN
strDSN = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath(cMDB)
Dim strERR
Dim strSQL
strSQL = "SELECT URL FROM Links order by group"
Dim strURL
Dim strXML

Dim objADO
Dim objRST
Dim objXML
Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
'Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")

Set objADO = Server.CreateObject("ADODB.Connection")
objADO.Open strDSN

Set objRST = Server.CreateObject("ADODB.Recordset")
objRST.Open strSQL, objADO

Do While Not objRST.EOF
     strURL = objRST("URL")

     If Left(LCase(strURL),7) <> "http://" Then
          strURL = "http://" & strURL
     End If

     objXML.Open "GET", strURL, False
     objXML.Send

     If Err.Number = 0 Then
          'strXML = "<xmp>" & objXML.ResponseText & "</xmp>"
          strERR = "+"
     Else
          strERR = "-"
     End If

     Response.Write "<br>" & strERR & "   " & objRST("URL")
     Response.Flush
     Err.Clear
     objRST.MoveNext
Loop

objRST.Close
Set objRST = Nothing

objADO.Close
Set objADO = Nothing
Set objXML = Nothing
%>
hi markhoy,

in planet-source-code and hotscripts, which category should i go to.....if i serach they return other scripts rather than asp.....
Avatar of Gary
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept Answer by markhoy

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer