Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2561 > unrolled thread
| Started by | Corey Richardson <kb1pkl@aim.com> |
|---|---|
| First post | 2011-04-04 07:01 -0400 |
| Last post | 2011-04-04 07:01 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: using python to post data to a form Corey Richardson <kb1pkl@aim.com> - 2011-04-04 07:01 -0400
| From | Corey Richardson <kb1pkl@aim.com> |
|---|---|
| Date | 2011-04-04 07:01 -0400 |
| Subject | Re: using python to post data to a form |
| Message-ID | <mailman.0.1301914894.9059.python-list@python.org> |
On 04/04/2011 01:36 AM, Littlefield, Tyler wrote:
> Hello:
> I have some data that needs to be fed through a html form to get
> validated and processed and the like. How can I use python to send data
> through that form, given a specific url? the form says it uses post, but
> I"m not really sure what the difference is. would it just be:
> http://mysite.com/bla.php?foo=bar&bar=foo?
> If so, how do I do that with python?
>
import urllib
import urllib2
url = "http://www.foo.com/"
data = {"name": "Guido", "status": "BDFL"}
data = urllib.urlencode(data)
request = urllib2.Request(url, data)
response = urllib2.urlopen(request)
page = response.read()
So yeah, passing in a Request object to urlopen that has some
urlencode'ed data in it.
--
Corey Richardson
Back to top | Article view | comp.lang.python
csiph-web