本文实例讲述了python实现的下载网页源码功能。分享给大家供大家参考,具体如下:
#!/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中了
运行效果图如下:
以上就是python实现网页中下载的功能实例的详细内容。
