472,332 Members | 1,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,332 software developers and data experts.

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 23913
* 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Thomas Scheiderich | last post by:
I am trying to understand Session variables and ran into a question on how they work with data that is passed. I have an HTM file that calls an...
1
by: khawar | last post by:
my application is in asp.net using C# hi guys having a complicated problem i am using payflowlink to process CC payments I have to send a httppost...
2
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data...
1
by: Manuel | last post by:
I have to log into a website and retrieve some information. The problem is that the post isn't "normal". I'm used to passing post values in the form...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can...
24
by: moriman | last post by:
Hi, The script below *used* to work. I have only just set up a server, PHP etc again on my Win98 system and now it doesn't? On first loading...
9
by: c676228 | last post by:
Hi, I am new to this discussion forum. I started to post questions on this forum since this Jan. and got many good responses and I am very...
3
by: JansenH | last post by:
We have implemented a 'HTTP Post' client in C# that posts Xml documents to a webserver. This is working fine if the post rate is one post for every...
10
by: Peter Michaux | last post by:
Hi, All Ajax libraries I've read use encodeURIComponent() on the name- value pairs extracted from forms before POST ing the result to the server...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.