HELP urllib POST can't get it to work

Siggy Brentrup bsb at winnegan.de
Fri Mar 30 05:56:47 EST 2001


"mike mcleod" <mike.mcleod at bt.com> writes:

> My code:
> 
> import urllib
> params = urllib.urlencode({'address': '07', 'identity': 'me',
>                            'resultpg':'html/sendresult.html', 'message':
> 'test',
>                            'fPage':'true',
>                            })
> f = urllib.urlopen("http://www.samemachine.uk/bin/afunc.pl?", params)
> print f.read()
> 
> It looks like the order of the params come out different in the urlopen.
> But because the server will only accept in the order shown it fails.
> I have tried to do this using basic sockets but don't know how to get that
> work without lots of reading.

>From looking at 2.1b1 lib/urllib.py: use a list of pairs instead of a
dictionary (untested)

params = urllib.urlencode( [('address','07'), ('identity','me'),
                           ...

HTH
  Siggy

-- 
Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/
****** ceterum censeo javascriptum esse restrictam *******





More information about the Python-list mailing list