PYTHON HTTP POST

lilanidhaval at gmail.com lilanidhaval at gmail.com
Wed Jan 14 10:03:53 CET 2009


Hi,

I need one complete example of how to do a http post to any site.
I have tried making a POST to google but all I am returned with is a
405 error.
I don't want to use Pygoogle as I want to try and do this with other
sites.
I am also having problems inputing with the param
I have tried Mechanize. There are no problems with getting data only
posting.

>>> headers = {'Content-Type': 'text/html; charset=ISO-8859-1',
...         'User-Agent':'Mozilla/4.0',
...         'Content-Length':'7'}
>>> conn = httplib.HTTPConnection("www.google.com")
>>> conn.request("POST","/search",params,headers)
>>> r2 =  conn.getresponse()
>>> print r2.status, r2.reason
405 Method Not Allowed

Regards,
Dhaval



More information about the Python-list mailing list