By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,097 Members | 1,529 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,097 IT Pros & Developers. It's quick & easy.

How to send a POST request?

P: n/a
kj

Hi. Sorry for this very clueless question, but how does one write
in Python an HTTP client that can send a POST request? The modules
I've found (e.g. urllib, urllib2), as far as I can tell, seem to
be limited to GET requests. (I could be wrong though; please
correct me if this is so.)

TIA!

kynn

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Jun 27 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
kj
In <g2**********@reader2.panix.comkj <so***@987jk.com.invalidwrites:
>Hi. Sorry for this very clueless question, but how does one write
in Python an HTTP client that can send a POST request? The modules
I've found (e.g. urllib, urllib2), as far as I can tell, seem to
be limited to GET requests. (I could be wrong though; please
correct me if this is so.)
Sorry, my mistake. I now see that urllib2 handles POSTs too.

kynn

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Jun 27 '08 #2

P: n/a
The original urllib module will do it too, if you pass a data keyword
argument to urllib.urlopen:

u = urllib.urlopen('http://www.domain.com/cgi-bin/cgi.py',
data=urllib.urlencode({'name': 'pythonguy'}))
On Fri, Jun 6, 2008 at 6:04 PM, kj <so***@987jk.com.invalidwrote:
In <g2**********@reader2.panix.comkj <so***@987jk.com.invalidwrites:
>>Hi. Sorry for this very clueless question, but how does one write
in Python an HTTP client that can send a POST request? The modules
I've found (e.g. urllib, urllib2), as far as I can tell, seem to
be limited to GET requests. (I could be wrong though; please
correct me if this is so.)

Sorry, my mistake. I now see that urllib2 handles POSTs too.

kynn

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
--
http://mail.python.org/mailman/listinfo/python-list
Jun 27 '08 #3

P: n/a
On Jun 7, 6:17 am, "Jeff McNeil" <j...@jmcneil.netwrote:
The original urllib module will do it too, if you pass a data keyword
argument to urllib.urlopen:

u = urllib.urlopen('http://www.domain.com/cgi-bin/cgi.py',
data=urllib.urlencode({'name': 'pythonguy'}))

On Fri, Jun 6, 2008 at 6:04 PM, kj <so...@987jk.com.invalidwrote:
In <g2cc24$63...@reader2.panix.comkj <so...@987jk.com.invalidwrites:
>Hi. Sorry for this very clueless question, but how does one write
in Python an HTTP client that can send a POST request? The modules
I've found (e.g. urllib, urllib2), as far as I can tell, seem to
be limited to GET requests. (I could be wrong though; please
correct me if this is so.)
Sorry, my mistake. I now see that urllib2 handles POSTs too.
kynn
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
--
http://mail.python.org/mailman/listinfo/python-list
check this link for http post:
http://love-python.blogspot.com/2008...l-by-http.html

regards,
Subeen
Jun 27 '08 #4

P: n/a
kj


Thanks to Jeff and subeen for the helpful comments and suggestions.

Kynn
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.