#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()

相关文章:

  • 2021-10-29
  • 2022-12-23
  • 2021-06-04
  • 2023-02-01
  • 2021-04-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2021-06-01
  • 2021-04-25
相关资源
相似解决方案