ClientForm -- HTML form handling
http://wwwsearch.sourceforge.net/ClientForm ClientForm 0.0.2a WARNING: this is an alpha release. The API may change, and don't expect everything to work properly! 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 is a port (more-or-less) of Gisle Aas' Perl module HTML::Form, from the libwww-perl library. import ClientForm import urllib2 request = urllib2.Request("http://www.acme.com/form.html") response = urllib2.urlopen(request) forms = ClientForm.ParseResponse(response) form = forms[0] form["author"] = "Gisle Aas" request2 = form.click("Thanks") response2 = urllib2.urlopen(request2) print result2.geturl() print result2.info() # headers for line in result2.readlines(): # body print line All of the standard input types are supported: TEXT, PASSWORD, FILE, HIDDEN, BUTTON, RESET, IMAGE, SUBMIT, CHECKBOX, SELECT/OPTION and RADIO. TEXTAREA and FILE (for file upload) are not yet supported, but will be in a future version. Python 2.0 or above is required. I will backport to 1.5.2 later. To run the tests, you need the unittest module (from PyUnit). John
participants (1)
-
John J. Lee