httplib、urllib2使用方式

httplib的使用方式

import httplib


http_client = None

http_client = httplib.HTTPConnection('192.168.217.130', 8080, timeout=30)
http_client.request('GET', '/jenkins/api/json?pretty=true')

response = http_client.getresponse()
print response.status
print response.read()

urllib2的使用方式

import urllib2

response = urllib2.urlopen('http://192.168.217.130:8080/jenkins/api/json?pretty=true')
print response.read()

你可能感兴趣的:(httplib、urllib2使用方式)