#!/usr/bin/python
import httplib
httpconn = httplib.HTTPConnection("www.baidu.com")
httpconn.request("GET", "/index.html")
resp = httpconn.getresponse()
if resp.reason == "OK":
resp_data = resp.read()
print resp_data
print len(resp_data)
httpconn.close()
要下载的网页源码被读取到了resp_data中了,但是到底能存储多少长度的文本,我也没有测试过。