Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

How to send a POST request?

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


socyl at 987jk

Jun 6, 2008, 3:00 PM

Post #1 of 5 (5579 views)
Permalink
How to send a POST request?

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.
--
http://mail.python.org/mailman/listinfo/python-list


socyl at 987jk

Jun 6, 2008, 3:04 PM

Post #2 of 5 (5556 views)
Permalink
Re: How to send a POST request? [In reply to]

In <g2cc24$638$1 [at] reader2> kj <socyl [at] 987jk> writes:

>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


jeff at jmcneil

Jun 6, 2008, 5:17 PM

Post #3 of 5 (5553 views)
Permalink
Re: How to send a POST request? [In reply to]

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 <socyl [at] 987jk> wrote:
> In <g2cc24$638$1 [at] reader2> kj <socyl [at] 987jk> writes:
>
>>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
>
--
http://mail.python.org/mailman/listinfo/python-list


tamim.shahriar at gmail

Jun 6, 2008, 10:06 PM

Post #4 of 5 (5551 views)
Permalink
Re: How to send a POST request? [In reply to]

On Jun 7, 6:17 am, "Jeff McNeil" <j...@jmcneil.net> wrote:
> 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.invalid> wrote:
> > In <g2cc24$63...@reader2.panix.com> kj <so...@987jk.com.invalid> writes:
>
> >>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/04/get-content-html-source-of-url-by-http.html

regards,
Subeen
--
http://mail.python.org/mailman/listinfo/python-list


socyl at 987jk

Jun 7, 2008, 11:25 AM

Post #5 of 5 (5537 views)
Permalink
Re: How to send a POST request? [In reply to]

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.
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.