469,349 Members | 1,646 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,349 developers. It's quick & easy.

GET and POST

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)
print f.read()

my contact tell me i must do a GET or fuseaction and POST for other param.

i dont know how to do this and if its possible.
someone tell me its ok to do that, but how in python?

i dont unsderstand the different between GET and POST but i know how to code
it separately.

thx in advance.

Jul 18 '05 #1
5 23802
* franck (op*@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

Jul 18 '05 #2
i know how to do a GET.
:) i have this example.
my contact tell my i must do a get AND a post :/

GET to fuse param et POST for the others.

dont know how do that.

"Jeremy Jones" <za******@bellsouth.net> a écrit dans le message news:
ma**********************************@python.org...
* franck (op*@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

Jul 18 '05 #3
franck wrote:
i know how to do a GET.
:) i have this example.
my contact tell my i must do a get AND a post :/

GET to fuse param et POST for the others.


Without knowing urllib, I would infer from the rest of the code that
you'd want to do something like this:

getparams['fuseaction'] = '*****'
postparams['num_card'] = '*****'

getparams = urllib.urlencode(getparams)
postparams = urllib.urlencode(postparams) # may not be necessary
f = urllib.urlopen("http://bidule.com?%s" % getparams, postparams)

--
Brian
Jul 18 '05 #4
Brian Victor <bh**@psu.edu> writes:
franck wrote:
i know how to do a GET.
:) i have this example.
my contact tell my i must do a get AND a post :/

GET to fuse param et POST for the others.


Without knowing urllib, I would infer from the rest of the code that
you'd want to do something like this:

getparams['fuseaction'] = '*****'
postparams['num_card'] = '*****'

getparams = urllib.urlencode(getparams)
postparams = urllib.urlencode(postparams) # may not be necessary
f = urllib.urlopen("http://bidule.com?%s" % getparams, postparams)


It seems unlikely that that's what is required (but you never
know...).

If the OP can post the HTML or a link, it would be rather easier to
say what the problem is!
John
Jul 18 '05 #5
"franck" <op*@opo.com> wrote in message
news:l9***************@newsr2.u-net.net...
i know how to do a GET.
:) i have this example.
my contact tell my i must do a get AND a post :/
In which case your contact is likely talking through his or her hat. GET and
POST are HTTP methods. In any given interaction the client can do either a
GET or a POST (or one of a number of other methods: the operative word here
is ONE).
GET to fuse param et POST for the others.

dont know how do that.

I suspect what your contact means is that you have to provide the value of
(I presume you mean) fuseaction encoded in the URL, and that the rest must
be provided as POST data. This is a somewhat bizarre requirement (and their
server is obviously not written in Python, but that's another thread ...).

Try something like:

params = {}

params['user'] = '***';
params['password'] = '**********';
params['num_card'] = '******';
params['date_of_birth'] = '****';

params = urllib.urlencode(params)
f = urllib.urlopen("http://bidule.com?fuseaction=*****",params)
print f.read()

and see if that works. If not, go back to your contact for further
enlightenment. Do they mean two operations or just one?

regards
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/

Jul 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Thomas Scheiderich | last post: by
1 post views Thread by Manuel | last post: by
10 posts views Thread by glenn | last post: by
24 posts views Thread by moriman | last post: by
9 posts views Thread by c676228 | last post: by
3 posts views Thread by JansenH | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.