using urllib or httplib to post with ENCTYPE=mulitpart/form-data

John J. Lee jjl at pobox.com
Thu Jun 5 20:06:49 CEST 2003


Kevin Carlson <khcarlso at bellsouth.net> writes:
[...]
> >According to Kevin Carlson  <khcarlso at bellsouth.net>:
> >
> >> I actually only need to send a couple of text inputs to the form,
> >> but no matter what, the host system acts like I input nothing into
> >> the form.  I have tried this:
[...]
> Thanks for help on this one -- I got the first POST working.  It was a
> problem with formatting the multipart/form-data.  Once I got the
> proper format it worked fine.  Interesting you should bring up
> cookies, though...

And as I just replied to Kevin, though he successfully solved the
problem by sniffing browser traffic (certainly often the quickest way
to get something working, though things can get messy that way), I
just realised that, contrary to my own statment, ClientForm *would*
have worked (barring bugs...).  I forgot that the whole form gets sent
back as multipart/form-data.  You don't need any FILE control for it
to work, and as long as the HTML says to use that encoding (or you ask
for it explicitly), it should work fine (the alpha version, that is).


> The response from the POST returns a cookie that I need to pass along
> to the host on the subsequent request.  I don't see and methods in
> httplib to deal with cookies directly, nor can I find any in the
> HTTPResponse.py source that allow me to extract the cookie from the
> response.  I'm sure I'm missing something.  Any additional pointers?

http://wwwsearch.sourceforge.net/ClientCookie/

:-)

If this is a public site, please let me know the URL: I haven't found
a public site that doesn't require a signup and that uses both cookies
and forms that would be good for example code (not that I've looked
very hard...).


John




More information about the Python-list mailing list