httplib-Python

#coding:utf-8
import htmllib
import httplib2

import httplib

h1 = httplib.HTTPConnection("www.python.org")

h1.request("GET", "/")
r1 = h1.getresponse()
print r1.status, r1.reason
data1 = r1.read()
print data1

import httplib, urllib

params = urllib.urlencode({'@number': 12524, '@type': 'issue', '@action': 'show'})
headers = {"Content-type": "application/x-www-form-urlencoded",
           "Accept": "text/plain"}
conn = httplib.HTTPConnection("bugs.python.org")
conn.request("POST", "", params, headers)
response = conn.getresponse()
print response.status, response.reason
data = response.read()

  

posted @ 2016-03-16 16:00  gopher-lin  阅读(135)  评论(0编辑  收藏  举报