using python to post data to a form

Corey Richardson kb1pkl at
Mon Apr 4 07:01:08 EDT 2011

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:
> If so, how do I do that with python?

import urllib
import urllib2

url = ""
data = {"name": "Guido", "status": "BDFL"}

data = urllib.urlencode(data)
request = urllib2.Request(url, data)
response = urllib2.urlopen(request)

page =

So yeah, passing in a Request object to urlopen that has some
urlencode'ed data in it.
Corey Richardson

More information about the Python-list mailing list