This is the first stable release of ClientForm 0.2.
(See below for the list of changes since 0.2.1b.)
Many improvements have been made as part of the 0.2 release, thanks
largely to Gary Poster, Benji York and their employer Zope Corporation
as part of their work on zope.testbrowser. These include:
* 0.1 backwards compatibility mode (backwards_compat switch).
* Greatly improved support for labels, including control labels.
* Added first-class support for list items and labels.
* A few methods have been added, and many superfluous methods
* The example script on the web page / README.html is now an
executable script in the examples directory, that runs against a
test page on the wwwsearch.sourceforge.net site.
* Label matching is now by substring (after compression of
whitespace), not by exact string equality.
* Support for list item ids.
* Finding controls or items now raises AmbiguityError if no nr
argument is supplied and the other arguments do not uniquely
identify the control or item. The old behaviour is restored by
* Fix multiple identical list item behaviour.
* Fixed a bug where disabled list items were successful (got sent back
to the server).
* More intuitive disabled list item behaviour.
* Large sections of the module have been reimplemented using classes
Item and Label, making for better code.
* Added ListControl.get(), ListControl.get_items(),
HTMLForm.set_value_by_label(), and HTMLForm.get_value_by_label()
* Applied patch from Titus Brown to add .clear() method to all
* The following ListControl methods have been deprecated:
* The following HTMLForm methods have been deprecated:
* The by_label argument of the following methods has been deprecated:
* Added support for setuptools / EasyInstall / Python Eggs.
* Make entitydefs more sane. Expose entitydefs in ParseFile /
Changes since 0.2.1b:
* Fixes to setup.py &c.
* Follow IE and Firefox on algorithm for choosing MIME boundary --
servers are buggy on this.
* Fix POST multipart/form-data parameter ordering (patch from
Balazs Ree) and ImageControl ordering.
* Fix .fixup() of disabled select with no selected options (John
* Encoding fixes.
* Add BeautifulSoup support (not yet well tested).
* Switch from htmllib to sgmllib.
* Add form name to str(HTMLForm).
* Make parser debugging a bit easier.
Requires Python 2.0 or newer.
ClientForm is a Python module for handling HTML forms on the client
side, useful for parsing HTML forms, filling them in and returning the
completed forms to the server. It developed from a port of Gisle Aas'
Perl module HTML::Form, from the libwww-perl library, but the
interface is not the same.
from urllib2 import urlopen
from ClientForm import ParseResponse
forms = ParseResponse(urlopen("http://www.example.com/form.html"),
form = forms
form["author"] = "Gisle Aas"
# form.click() returns a urllib2.Request object
# (see HTMLForm.click.__doc__ if you don't have urllib2)
response = urlopen(form.click("Thanks"))