Webbots, Spiders, and Screen Scrapers - Michael Schrenk [25]
Form Handlers, Data Fields, Methods, and Event Triggers
Web-based forms have four main parts, as shown in Figure 5-2:
A form handler
One or more data fields
A method
One or more event triggers
I'll examine each of these parts in detail and then show how a webbot emulates a form.
Figure 5-2. Parts of a form
Form Handlers
The action attribute in the
Listing 5-1: Data fields in a HTML form
Methods
The form's method describes the protocol used to send the form data to the form handler. The most common methods for form data transfers are GET and POST.
The GET Method
You are already familiar with the GET method, because it is identical to the protocol you used to request web pages in previous chapters. With the GET protocol, the URL of a web page is combined with data from form elements. The address of the page and the data are separated by a ? character, and individual data variables are separated by & characters, as shown in Listing 5-2. The portion of the URL that follows the ? character is known as a query string.
URL http://www.schrenk.com/search.php?term=hello&sort=up
Listing 5-2: Data values