a start
This commit is contained in:
commit
c531fc3238
2 changed files with 43 additions and 0 deletions
34
src/main.rkt
Normal file
34
src/main.rkt
Normal file
|
@ -0,0 +1,34 @@
|
|||
#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)
|
9
test/test.html
Normal file
9
test/test.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<a href="/dev/null">/dev/null</a>
|
||||
<br>
|
||||
<a href="/etc/passwd">/etc/passwd</a>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue