POST request

Chad McDaniel chadm at sgi.com
Fri Apr 9 13:29:53 EDT 1999


gscot at my-dejanews.com writes:

> To All: 	I would like to write a short program that would play a game
> found on the Internet. I cannot find any documentation on how to make a POST
> request. It is a stock market game. You fill out a form with the symbol and
> number of share you want to buy or sell. The form uses the POST method to
> send the data. Since I cannot just put this information in the url I am not
> sure how to write a program to automate this procese. Is there any way to do
> that with Python. Thank you for your help.     Gary
> 

If you are asking how you can make a POST request to a HTTP web server
using python as the client then yes, you can do this with urllib which
should be part of your python installation. urllib.urlopen() normally
uses GET, but if you supply a second data argument it will send that
data along as the body of a POST. With python 1.5.2 there is also a
very hand urllib.urlencode() function to transform a python
dictionary into something suitable for the body of a POST request.

-- 
-chad




More information about the Python-list mailing list