html POST in python

John J. Lee jjl at
Tue Jun 29 21:45:43 CEST 2004

simoninusa2001 at (simo) writes:

> # create array of name/value pairs
> self.params = urllib.urlencode({'user': 'fred', 'password': 'hax0r5'})
> # send http-post
> request = urllib.urlopen("", params)
> # read back each line of reply
> line = request.readline()

That's a generic POST, but there's a bit more to it for file upload,
which is what the OP seemed to want.

If you don't want the HTML parsing that my rather heavy ClientForm
library does (heavyweight for the job it does, anyway), there are
functions lying around for doing file upload in traditional procedural
style.  Can't remember where, but no doubt they're Google-able for.


More information about the Python-list mailing list