import urllib2 import urllib url = 'http://localhost/12.php' data = {} data['cmd']='whoami' data = urllib.urlencode(data) try: content = urllib2.urlopen(url, data) print content.read() except urllib2.HTTPError,E: print 'httperror' print E.read() except urllib2.URLError,e: print 'urlerror' print e.reason