[racket] Just how to get and print a web page

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Sat Oct 29 09:19:25 EDT 2011

Sam Tobin-Hochstadt wrote at 10/29/2011 07:15 AM:
> #lang racket
> (require net/url)
> (define (get url)
>    (get-impure-port (string->url url)))
> (port->lines (get "http://www.google.com"))

Also, if you want to process the HTML of that page, you might wish to 
get the HTML into an SXML/xexp format like this does:

#lang racket/base
(require net/url
          (planet neil/html-parsing))
(call/input-url (string->url "http://www.google.com/")
                 get-pure-port
                 html->xexp)

This SXML can be processed using tools like SXPath and "sxml-match".

This SXML can also be processed using low-level Racket list-processing 
procedures like "car", "cdr", and "pair?" and recursive procedures.

-- 
http://www.neilvandyke.org/


Posted on the users mailing list.