A web client is just a machine connected to the Internet, running a computer program that sends requests for content to web servers, and processes what comes back, typically HTML files. Although browsers are far and way the most common web client, any program with the appropriate network code can talk to a web server.
There are two packages of code available for Franz's Allegro Lisp that make it easy to write simple web clients:
- the net.aserve.client package that comes with AllegroServe has a function do-http-request that sends a request to a URL and returns the content as a string.
- the open-source net.html.parser package, available at http://opensource.franz.com/xmlutils/, defines a parse-html function that can parse the string returned by do-http-request into Lisp-friendly nested list.
do-http-request is very easy to use. Here's a simple example:
This will return a string with the entire HTML for the page at http://www.cs.northwestern.edu/. Try it and see.
Documentation on do-http-request is part of the AllegroServe documentation.
parse-html is also very easy to use. Here's a simple example:
This will return the list:
(:html (:body "Hello"))
This is the list format that the HTML generator macro, html, uses to generate HTML text. This list format makes it very simple to write Lisp code to extract material stored in tags in an HTML file.
The xmlutils package also includes parse-xml which is for parsing XML files.
Documentation on parse-html comes with the xmlutils library.
Caution: Be sure to compile phtml.cl and load phtml.fasl version.