#coding=utf-8
import httplib,urllib
#get調用
httpClient=None
try:
params=urllib.urlencode({'account':'1350000','password':'0000','roleType':1,'zoneCode':'北京市'})
headers={"Content-type": "application/x-www-form-urlencoded"
, "Accept": "text/plain"}
httpClient=httplib.HTTPConnection("xxx.xxx.com",80,timeout=30)
httpClient.request("POST","/educmbs/member/login.htm",params,headers)
response=httpClient.getresponse()
print response.status
print response.reason
print response.read()
print response.getheaders()
except Exception,e:
print e
finally:
if httpClient:
httpClient.close()
#post
#coding=utf-8
import httplib
httpClient=None
try:
httpClient=httplib.HTTPConnection('xxx.xxx.com',80,timeout=30)
httpClient.request("GET",'/home/index.htm')
#response 是httpresponse對象
response= httpClient.getresponse()
print response.status
print response.reason
print response.read()
except Exception,e:
print e
finally:
if httpClient:
httpClient.close()