Updated 2006-04-20 14:57:35

US Given a file sitemap.txt with one URL per line, the validator submits them to the W3C-Validator and generates a file sitemap.val containing the URLs and the number of errors on that page.

See Sitemap Generator to create a sitemap.txt file.
 #!/bin/sh
 # the next line restarts using -*-Tcl-*-sh \
 exec tclsh "$0" ${1+"$@"}

 package require http

 proc validate {url} {
   set query [::http::formatQuery uri $url]
   set p [::http::geturl http://validator.w3.org/check?$query]
   upvar 0 $p state
   array set arr $state(meta)
   if {$arr(X-W3C-Validator-Status) eq "Valid"} {
     set res 0
   } else {
     set res $arr(X-W3C-Validator-Errors)
   }
   return [list $url $res]
 }

 set ifd [open sitemap.txt r]
 set ofd [open sitemap.val w]
 while {[gets $ifd line] != -1} {
   puts $line
   puts $ofd [validate $line]
 }
 close $ofd
 close $ifd

Category Internet