weather.ss
dvanhorn <[email protected]>
| Newsgroups | gmane.org.ballistichelmet.lambda |
|---|---|
| Message-ID | <[email protected]> |
#! /home/bh/local/bin/mzscheme -r
;; weather.ss
;; This script spits out an HTML fragment reporting weather in your area with
;; with a link to the World Weather Information Service.
(require (lib "xml.ss" "xml")
(lib "match.ss")
(lib "url.ss" "net"))
;; See http://www.undergroundlondon.com/weather/
;; for finding the RSS feed for your city.
;; This script works on the "title" feed type.
(define url
(string->url
"http://www.undergroundlondon.com/weather/world.rss/093/c00729f?type=title"))
(define (get-rss)
(xml->xexpr
((eliminate-whitespace '(|rdf:RDF| channel item) (lambda (x) x))
(document-element (call/input-url url get-pure-port read-xml)))))
(match (get-rss)
(('|rdf:RDF| _ ('channel . _) . items)
(map
(match-lambda
(('item _
('title _ title)
('link _ link)
('description _ desc) . _)
(printf "<p><em><a href=\"~a\">~a</a></em>: ~a</p>~n"
link title desc)))
items)))