GET and POST
Jeremy Jones
zanesdad at bellsouth.net
Thu Sep 11 10:42:56 EDT 2003
* franck (opo at opo.com) wrote:
> HI,
>
> this is my code
> params = {}
>
> params['fuseaction'] = '*****';
> params['user'] = '***';
> params['password'] = '**********';
> params['num_card'] = '******';
> params['date_of_birth'] = '****';
>
> params = urllib.urlencode(params)
> f = urllib.urlopen("http://bidule.com",params)
According to the urllib documentation (I've never used urllib, only
httplib), all you have to do is change:
f = urllib.urlopen("http://bidule.com",params)
to
f = urllib.urlopen("http://bidule.com?%s" % params)
Here is the example from the documentation for a GET (found at
http://www.python.org/doc/current/lib/node415.html):
>>> import urllib
>>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
>>> f = urllib.urlopen("http://www.musi-cal.com/cgi-bin/query?%s" % params)
>>> print f.read()
I haven't whether this works or not, so I take no responsibility for any
damage caused by this code ;-)
Jeremy Jones
More information about the Python-list
mailing list