網頁

python post https request

import httplib, urllib

host = 'abc.def.gov.tw'
url = ''

values = {
  'queryBy' : 'ID',
  'key' : 'A123456789'
}

headers = {
    'User-Agent': 'python',
    'Content-Type': 'application/x-www-form-urlencoded',
}

values = urllib.urlencode(values)

conn = httplib.HTTPSConnection(host)
conn.request("POST", url, values, headers)
response = conn.getresponse()

data = response.read()

print 'Response: ', response.status, response.reason
print 'Data:'
print data