Java Reference
In-Depth Information
<city>St. Louis</city>
<state>MO</state>
<zip>63017</zip>
</employee>
</response>
The AJAX web browser application will take the above XML information and use the
DOM to parse it. The data extracted from the message will be displayed on the current web
page. The data will be displayed using the DOM.
Again, it is not necessary to use XML with an AJAX application. Some AJAX applications
will transmit HTML or raw text messages. XML is particularly convenient because JavaScript
can use the DOM to parse it.
What AJAX Means to Bots
Supporting AJAX from a bot is very similar to supporting JavaScript from a bot. Just as
with JavaScript, the user's web browsing experience boils down to a series of HTTP requests.
The web server is not aware that AJAX is being used. The web server is simply accepting
HTTP requests and issuing HTTP responses. How these responses are interpreted is up to
the web browser.
To create a bot that supports an AJAX site, you must provide the same HTTP requests as
the AJAX web application. Your bot will then examine the responses and extract the needed
information from these responses.
There are two ways to do this. If you know JavaScript and how to use AJAX, you can
examine the target AJAX site and learn to construct the same requests as the AJAX applica-
tion. However, a much easier approach is to use a network analyzer to examine the AJAX web
site as you use it. The network analyzer will show you the format of the HTTP requests and
responses. This approach also allows you to not need an in-depth knowledge of AJAX.
Recipes
One of the quickest ways to determine how to create a bot for an AJAX site is to use a
network analyzer. The network analyzer will allow you to examine the HTTP requests and
responses that are sent between the web browser and the web server.
The first recipe for this chapter will show how to use a network analyzer to construct the
bot. This chapter will demonstrate two different recipes:
• Extract data from a non-XML based AJAX site
• Extract data from an XML based AJAX site
We will begin with a non-XML based AJAX site.
Search WWH ::




Custom Search