35 lines
867 B
Racket
35 lines
867 B
Racket
#lang racket
|
|
|
|
(require net/url
|
|
html
|
|
xml
|
|
xml/path)
|
|
|
|
(define verbose-mode (make-parameter #f))
|
|
|
|
(define uri
|
|
(command-line
|
|
#:program "linky-pinky"
|
|
#:once-each
|
|
[("-v" "--verbose") "Verbose output"
|
|
(verbose-mode #t)]
|
|
#:ps "Check dead links."
|
|
#:args (url/filename) ; expect one command-line argument: <url/filename>
|
|
;; return the argument as a filename to compile
|
|
url/filename))
|
|
|
|
(define (read-html-as-xexprs in)
|
|
(caddr
|
|
(xml->xexpr
|
|
(element #f #f 'root '()
|
|
(read-html-as-xml in)))))
|
|
|
|
(define (get-urls url)
|
|
(se-path*/list '(a #:href) (call/input-url
|
|
(string->url url)
|
|
get-pure-port
|
|
read-html-as-xexprs)))
|
|
|
|
;; (get-urls "file:///home/finga/src/linky-pinky/src/test.html")
|
|
(get-urls uri)
|