curl-and-python

Re: having a hard time converting PHP to Python

From: Nathan E. Moore <nate_at_redtetrahedron.org>
Date: Wed, 14 Nov 2007 16:13:52 -0500

--On Wednesday, November 14, 2007 6:41 PM +0100 Arye - GMail
<aryeh_at_bigfoot.com> wrote:

> Hello all,
> I am new to the list so sorry for the stupid questions...
>
> I have no success in converting this PHP code to Python:
<snip>
> Parameters = {'rm':'importFileContr',
> 'rf':'importProduct',
> 'sl':merchant_serial,
> 'FILENAME':'c:/webserver/htdocs/pp_files/pp_product.csv'}
># Do not forget '@' before the file to be called
>
> dataupdate=urllib.urlencode(Parameters)
>

Your PHP is doing a multipart/form-data post not a
application/x-www-form-urlencoded post. (at least according to the PHP
documentation. To do a multipart/form-data post from pycurl, you need to
use the HTTPPOST option. It's usage from python is a little different than
from c (or PHP) see
<http://pycurl.cvs.sourceforge.net/*checkout*/pycurl/pycurl/tests/test_post2.py?revision=1.13&content-type=text%2Fplain>
and
<http://curl.haxx.se/mail/curlpython-2007-03/0003.html>
for more details.

Nathan E. Moore
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2007-11-14