最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Python实现的下载网页源码功能示例
时间:2017-06-14 编辑:简简单单 来源:一聚教程网
本文实例讲述了Python实现的下载网页源码功能。分享给大家供大家参考,具体如下:
代码如下 | 复制代码 |
#!/usr/bin/python importhttplib httpconn=httplib.HTTPConnection("www.baidu.com") httpconn.request("GET","/index.html") resp=httpconn.getresponse() ifresp.reason=="OK": resp_data=resp.read() printresp_data printlen(resp_data) httpconn.close() |
要下载的网页源码被读取到了resp_data中了
运行效果图如下:
-
下一个: Python爬虫DOTA排行榜爬取实例