网络爬虫:从python2到python3
来源:互联网 发布:淘宝号买卖平台 编辑:程序博客网 时间:2024/04/30 06:50
很久以前,python2的时候,简单的弄过一点爬虫程序,后来,到3之后,发现之前的好多程序都特么不能用了,最最基本的抓页面都不行了,就重新写了一个。
python2缩写版,大概是这样的,忘记了没验证
import urllib2response = urllib2.urlopen('http://www.baidu.com/')html = response.read()print html
python3详细版
import urllib.requestrequest = urllib.request.Request('http://www.baidu.com/')response = urllib.request.urlopen(request)if response.getcode() != 200: print("None!")else: html = response.read() # 如果返回结果不为空 if html is not None: # 还必须编码,不然格式不对 html = html.decode("utf-8") print(html) else: print("Maybe The Program is Error!")# 头信息print(response.info())
阅读全文
1 0
- 网络爬虫:从python2到python3
- 爬虫, 从python2 到 python3
- 从python2到python3
- Python2.x vs Python3——从 raw_input() 到 input()
- Python3爬虫从入门到自残(三):保存数据
- [Python3爬虫从入门到精通]中国大…
- python3网络爬虫框架
- 升级Python2.7到Python3
- Linux升级python2到python3
- nutch从搜索引擎到网络爬虫
- python 3.x中列表排序问题,从python2.x过渡到python3.x
- 将pjsip的python扩展从python2.4升级到python3.2
- 把项目从Python2.x移植到Python3.x的经验总结
- Python3网络爬虫(五):Python3安装Scrapy
- Python3网络爬虫(四): 登录
- Python3:网络爬虫(1)
- 基于python3的网络爬虫
- python3.0 网络爬虫 4
- Docker第二篇:架构的基本组成
- Handler 设置首界面页面跳转
- vin码详解以及自动扫描vin码识别应用
- 如何让自己变得更加自信、多产和富有
- redisson分布式锁的实现
- 网络爬虫:从python2到python3
- web项目中有jar包还报错ClassNotFoundException
- 二叉树的创建和递归遍历
- ZOJ
- 第一个Hibernate小例子
- Windows 安装GIT
- 简易的单例模式与对象池
- 文章标题
- C++ operator关键字(重载操作符)