#reader(lib "htdp-beginner-reader.ss" "lang")((modname get-ip-address) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
(require "moby/net")
(require "moby/parser")
(require "moby/gui-world")
(define initial-world "unknown")
(define (description w)
w)
(define (refresh w)
(extract-ip-address
(xml->s-exp
(get-url "http://ip.hashcollision.org/"))))
(define (extract-ip-address an-xexpr)
(cond
[(string? an-xexpr)
""]
[(and (pair? an-xexpr)
(equal? (first an-xexpr) 'p))
(third an-xexpr)]
[else
(extract-ip-address/children (rest (rest an-xexpr)))]))
(define (extract-ip-address/children xs)
(cond
[(empty? xs)
""]
[(string=? (extract-ip-address (first xs)) "")
(extract-ip-address/children (rest xs))]
[else
(extract-ip-address (first xs))]))
(define view
(col
(message description)
(button "Refresh!" refresh)))
(big-bang initial-world view)