scripting browsers from Python

Olivier Favre-Simon olivier.favre-simon at
Wed Jun 1 06:45:03 CEST 2005

On Tue, 31 May 2005 00:52:33 -0700, Michele Simionato wrote:

> I would like to know what is available for scripting browsers from
> Python.
> For instance, let me to perform GET requests, but I
> would like
> to do POST requests too. I don't want to use urllib to emulate a
> browser, I am
> interested in checking that browser X really works as intended with my
> application. Any suggestion?
>            Michele Simionato


I use it for automation of POSTs of entire image directories to hosts.

Works above urllib2.

You access forms by name or indice, then you access HTML elements as a
dict attribute of the form.

Support file upload within POST.

The only drawback I've found are:
- does not support nested forms (since forms are returned in a list)
- does not like ill-formed HTML (Uses HTMLParser as the underlying parser.
you may pass a parser class as parameter (say SGMLParser for greater
acceptance of stupid HTML code) but it's tricky because there is no well
defined parser interface)

Hope this helps.

More information about the Python-list mailing list