473,662 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GET and POST

HI,

this is my code
params = {}

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

params = urllib.urlencod e(params)
f = urllib.urlopen( "http://bidule.com",par ams)
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 23987
* 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.urlencod e(params)
f = urllib.urlopen( "http://bidule.com",par ams)

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",par ams)
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.urlencod e({'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******@bells outh.net> a écrit dans le message news:
ma************* *************** ******@python.o rg...
* 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.urlencod e(params)
f = urllib.urlopen( "http://bidule.com",par ams)

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",par ams)
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.urlencod e({'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.urlencod e(getparams)
postparams = urllib.urlencod e(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.urlencod e(getparams)
postparams = urllib.urlencod e(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.urlencod e(params)
f = urllib.urlopen( "http://bidule.com?fuse action=*****",p arams)
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
3120
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 ASP file and sends the name either by GET or POST. When I find is that if I send the value by the GET method, response.write("From QueryString: " & Request.QueryString("usernamefromform") & "<br><br>")
1
4771
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 to their servers. The problem is how do i do a post where i get these values like the amount from the database. eg of the post: <form method="post" action="https://payflowlink.verisign.com/payflowlink.cfm"> <input type="hidden" name="name" value="john adams">
2
12548
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 and open display.asp in the current browser <form action="display.aspx" method="post" target="_blank"> will submit the form data and open display.asp in a new browser
1
2968
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 of: Variable1=Value1&Variable2=Value2 etc. I used Live Http Headers to retrieve the POST information, I included it at the end of this message. Can anyone tell me how to make THIS kind of post? Another thing, "Content-Type: multipart/form-data;
10
3418
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 get to their values easily to write to a database or continue to process on to the next page. I am now trying to learn ASP to see if we can replace some of our applications that were written in php with an ASP alternative. However, after doing many searches on google and reading a couple...
24
2872
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 this page, you would have $p = and the button image below it.
9
3086
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 appreciated to those who are willing to help with their expertise. That save me a lot of time and stress. I want to rate the post, but I only see questions "is this post helpful" and " why should I rate a post" link. I didn't see any thing "rate the post" link. I already sign into the community...
3
4909
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 20 seconds. But if the post rate is increased to one post for every 10 seconds the client start getting error 403 'forbidden' from the webserver after a short period of time. The webserver is IIS. The choking of the client/server communication when doing high frequency posting is due to that we...
10
15691
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 with and xmlhttprequest. I can understand why this encoding is required in the case of a GET request and the form data is attached as a URI query string; however, why is the encoding necessary for POST requests? Thanks,
0
8435
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8857
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8768
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8547
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4348
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.