Python3获取网页内容
2015-06-07 17:18
741 查看
import urllib.request headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0", "character":"utf-8"} opener = urllib.request.build_opener() opener.addheaders = [headers] html = opener.open("http://blog.csdn.net/wskinght").read() print(html.decode("utf-8"))
x = open("C:/cs.htm", encoding="utf-8").read()
相关文章推荐
- python编码问题总结
- Python图像处理(9):Hu矩
- python的zip函数
- Python定制类
- python中实现二分查找,插入排序,归并排序,快速排序
- Python图像处理(8):边缘检测
- python并行计算的简单实现--pp
- 使用virtualenv搭建python3开发环境
- Python类与继承
- python与内建函数重名
- python动态加载是否影响性能
- python学习之List和Tuple
- 初识Python
- Python面向对象编程基础
- python 2 给我自己看
- python中的下划线
- python学习笔记glob模块
- ThinkPython总结
- 使用python+selenium爬取学生信息并入库
- Python 中的struct