Here is an example using urllib and urllib2 for POST and GET:
POST If urlopen() has a second parameter, this is a POST request.
import urllib import urllib2 url = 'http://www.example.com' values = {'var' : 500} data = urllib.urlencode(values) response = urllib2.urlopen(url, data) page = response.read()
GET If urlopen() has one parameter, then this is a GET request.
import urllib import urllib2 url = 'http://www.example.com' values = {'var' : 500} data = urllib.urlencode(values) fullurl = url + '?' + data response = urllib2.urlopen(fullurl) page = response.read()
You can also use curl if you call it using os.system() .
Here are some useful links:
http://docs.python.org/library/urllib2.html#urllib2.urlopen
http://docs.python.org/library/os.html#os.system
source share