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)))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.