取得headers:
import httplib
conn = httplib.HTTPConnection('www.sohu.com')
conn.request('get', '/')
res = conn.getresponse()
#print res.status, res.reason
print res.getheaders()
取得内容:
#coding=gbk import httplib conn = httplib.HTTPConnection( "www.google.cn" ) conn.request( 'get' , '/' ) print conn.getresponse().read() conn.close()