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

Reply via email to