Java Reference
In-Depth Information
Next, the state name, capital, code and site are all extracted from the HTML download-
ed.
String name = this.extractNoCase(buffer,"<h1>", "</h1>", 0);
String capital = this.extractNoCase(buffer,
"Capital:<b></td><td>", "</td>", 0);
String code = this.extractNoCase(buffer,"Code:<b></td><td>",
"</td>", 0);
String site = this.extractNoCase(buffer,
"Official Site:<b></td><td><a href=\"", "\"", 0);
Once the data has been extracted, it is displayed.
System.out.println("State name:" + name);
System.out.println("State capital:"+ capital);
System.out.println("Code:"+code);
System.out.println("Site:"+site);
This recipe can be adapted to web sites that transfer HTML data with AJAX.
Recipe #10.2: A XML Based AJAX Site
Many AJAX sites use XML to transfer messages between the web browser and web serv-
er. This recipe will demonstrate how to write a bot for an AJAX web site that makes use of
XML. To see a web site that makes use of AJAX XML communication, examine the following
URL:
http://www.httprecipes.com/1/10/ajaxxml.php
This page allows you to search for a list of states. For example, if you enter the string
“Miss” you will see the states “Mississippi” and “Missouri”. You can see this in Figure 10.6.
Search WWH ::




Custom Search