Python HTTP POST
Joel Goldstick
joel.goldstick at gmail.com
Wed Jul 17 16:26:54 EDT 2013
On Wed, Jul 17, 2013 at 4:15 PM, John Gordon <gordon at panix.com> wrote:
> In <00ec2f9b-fcae-428c-8932-163e653dd71b at googlegroups.com> Matt Graves <
> tunacubes at gmail.com> writes:
>
> > How would I submit a python HTTP POST request to... for example, go to
> > google.com, enter "Pie" into the search box and submit (Search)
>
> Something like this:
>
> import urllib
> import urllib2
>
> # the google form search input box is named 'q'
> data = { 'q': 'Pie' }
>
> response = urllib2.urlopen('http://google.com', urllib.urlencode(data))
> print response.read()
>
> --
> John Gordon A is for Amy, who fell down the stairs
> gordon at panix.com B is for Basil, assaulted by bears
> -- Edward Gorey, "The Gashlycrumb Tinies"
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Many people find urllib and urllib2 to be confusing. There is a module
called requests which makes this stuff a lot easier. ymmv
http://docs.python-requests.org/en/latest/
--
Joel Goldstick
http://joelgoldstick.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130717/844ddfba/attachment.html>
More information about the Python-list
mailing list