Loading ...
Sorry, an error occurred while loading the content.

Validate Links in Web Sites

Expand Messages
  • Andy Young
    Hi, all I ve finished clip #2 to help with managing web sites. This one checks for valid links in a hard drive version of a website. This one has progress
    Message 1 of 10 , Jul 23, 2001
    • 0 Attachment
      Hi, all
      I've finished clip #2 to help with managing web sites. This one
      checks for valid links in a hard drive version of a website. This
      one has progress notices because of the time involved to run the
      clip. If anyone discovers a problem or has a suggestion to improve
      it please let me know.
      Thanks in advance.
      Andy

      ---------< start clip >---------
      H="LinkValidate"
      ;Andy Young <ajyoung@...>
      ;07/23/2001, 10:58:03 AM
      ;Adapted from sitemap clip by Stephen Riddle
      [stephen@...]
      ;
      ;----------------------[begin long line]---------------------------
      ^!Continue This Clip searches Web pages in directories and
      subdirectories for messed up href links. A list is then compiled
      providing invalid links sorted according to directory and web page
      file name. Note: Links within comments <-- --> are included. Links
      containing parentheses will generate false invalid links.
      ;-----------------------[end long line]----------------------------
      ;
      ^!ClearVariables
      ^!SetScreenUpdate Off
      ^!SetPasteIndent Off
      ^!SetWordWrap Off
      ;
      ;----------------------[begin long line]---------------------------
      ^!Set %directory%=^?[(T=D)Please give full path to directory you
      wish to search: ending in backslash=D:\My Documents\WWWDEV\]
      ;-----------------------[end long line]----------------------------
      ;
      ;
      ;----------------------[begin long line]---------------------------
      ^!Set %docname%=^?[What shall we call the finished document?
      =linkvalidate.txt]
      ;-----------------------[end long line]----------------------------
      ;
      ;
      ;----------------------[begin long line]---------------------------
      ^!Set %include%=^?[Do you wish to include
      subdirectories?==_Yes^=+|No^=^%EMPTY%]
      ;-----------------------[end long line]----------------------------
      ;
      ;
      ;----------------------[begin long line]---------------------------
      ^!Set %savewhere%=^?[(T=D)Where do you want to save finished
      document? =D:\My Documents\WWWDEV\]
      ;-----------------------[end long line]----------------------------
      ;
      ;Place all files matching your description in an array
      ^!SetScreenUpdate On
      ^!StatusShow Gathering Directory Information ...
      ^!SetScreenUpdate Off
      ^!Set %kindof%=*.*htm*;*.asp;*.xml;*.php
      ^!SetListDelimiter ^P
      ^!SetArray
      %items%=^$GetFiles("^%include%^%directory%";"^%kindof%";*;name)$
      ;sort array so that files in root directory are first
      ^!Set %counter%=1
      :loopsort
      ;check if each member of the array has more "\" than base directory
      ;
      ;----------------------[begin long line]---------------------------
      ^!If ^$StrCount("\";"^%directory%";False;False)$ <>
      ^$StrCount("\";"^%items^%counter%%";False;False)$ loopskip
      ;-----------------------[end long line]----------------------------
      ;
      ^!Append %dirtemp%=^%items^%counter%%|
      ^!GoTo loopcounter
      :loopskip
      ^!Append %subtemp%=^%items^%counter%%|
      :loopcounter
      ^!Inc %counter%
      ^!If ^%counter% > ^%items0% SKIP
      ^!GoTo loopsort
      :endloopsort
      ^!Set %itemtemp%=^%dirtemp%^%subtemp%
      ^!Set %itemtemp%=^$StrDeleteRight("^%itemtemp%";1)$
      ^!SetListDelimiter |
      ^!SetArray %items%=^%itemtemp%
      ^!Append %file%=List of files with any missing links in
      ^%directory%.^%NL%
      ^!Set %counter%=1
      :itemloop
      ^!If ^%counter% <> 1 newdir
      ^!Append %file%=^%NL%^%directory%
      ^!GoTo samedir
      :newdir
      ^!If "^$GetPath(^%items^%counter%%)$" = "^%oldpath%" samedir
      ^!Append %file%=^%NL%^$GetPath(^%items^%counter%%)$
      :samedir
      ^!SetScreenUpdate On
      ^!StatusShow Searching ^%items^%counter%% ...
      ^!SetScreenUpdate Off
      ^!Set %filecheck%=0
      ^!Open ^%items^%counter%%
      ^!FocusDoc
      ^!Jump DOC_START
      ;Create list of links
      :linkloop
      ^!ClearVariable %url%
      ^!ClearVariable %verlink%
      ^!Find "<a href=" SI
      ^!IfError EndLink
      ^!MoveCursor +2
      ^!Select URL
      ^!Find "(http)|(www)|(@)" IHRS
      ^!IfError validlink
      ^!Goto skiplink
      ;Check to see if link is accurate
      :validlink
      ^!Select URL
      ^!Set %url%=^$GetSelection$
      ^!Set
      %verlink%=^$GetExpandedName(^%url%;^$GetPath(^%items^%counter%%)$)$
      ^!InsertText ^%url%^%NL%^%verlink%
      ^!Set
      %verlink%=^$StrReplace("file:///D|/";"D:\";"^%verlink%";False;False)
      $
      ^!Set %verlink%=^$StrReplace("/";"\";"^%verlink%";False;False)$
      ^!Set
      %verlink%=^$StrReplace("%20";"^%SPACE%";"^%verlink%";False;False)$
      ^!IfFileExist "^%verlink%" skiplink
      :addlink
      ^!If "^%filecheck%" = "1" Skip_2
      ^!Append %file%=^%NL%^%TAB%^$GetFileName(^%items^%counter%%)$
      ^!Set %filecheck%=1
      ^!Append %file%=^%NL%^%TAB%^%TAB%^%url%
      :skiplink
      ^!Jump Select_End
      ^!Goto linkloop
      :EndLink
      ^!Close "^%items^%counter%%" DISCARD
      ^!IfError End
      ^!Set %oldpath%=^$GetPath(^%items^%counter%%)$
      ^!Inc %counter%
      ^!If ^%counter% > ^%items0% SKIP
      ^!GoTo itemloop
      ^!SetScreenUpdate On
      ^!StatusShow Creating Text File ...
      ^!SetScreenUpdate Off
      ^!Toolbar New Document
      ^!InsertHtml ^%file%
      ^!Save:As "^%savewhere%^%docname%"
      :end
      ^!SetScreenUpdate On
      ^!SetPasteIndent On
      ^!SetWordWrap On
      ^!ClearVariables
      ---------< end clip >-----------
    Your message has been successfully submitted and would be delivered to recipients shortly.