I am relatively new (as in a few days) to Python – I am looking for an example that would show me how to post a form to a website (say http://www.example.com).
I already know how to use Curl. Infact, I have written C+++ code that does exactly the same thing (i.e. POST a form using Curl), but I would like some starting point (a few lines from which I can build on), which will show me how to do this using Python.
Here is an example using urllib and urllib2 for both POST and GET:
POST – If
urlopen()has a second parameter then it is a POST request.GET – If
urlopen()has a single parameter then it is a GET request.You could also use
curlif you call it usingos.system().Here are some helpful links:
http://docs.python.org/library/urllib2.html#urllib2.urlopen
http://docs.python.org/library/os.html#os.system