Scripting HTTP POST - multipart/form-data

John J. Lee jjl at pobox.com
Tue Jul 20 01:39:53 CEST 2004


Jeff Shannon <jeff at ccvcorp.com> writes:

> I'm looking to script a routine file-upload through an HTTP server
> (which I don't have access to).  I've got specs on the CGI app that
> receives this upload (i.e. field names and expected contents).
[...]

Forgot to add: if I had to do this and wanted to use ClientForm (which
I certainly would ;-), I'd just write a snippet of HTML:

formHtml = """\
<form action="http://www.example.com/cgi-bin/spam.cgi">
  <input type="text" name="nrEmails" />

  <input type="checkbox" name="spamType" value="ludicrous" />
  <input type="checkbox" name="spamType" value="absurd" />
</form>
"""

import StringIO
from ClientForm import ParseFile

forms = ParseFile(StringIO.StringIO(formHtml), "http://www.example.com/")
...


Which is surely a very readable way of writing down such a spec :-)

I should point this out in the docs...


John



More information about the Python-list mailing list