python3 爬虫之requests模块使用总结
16lz
2021-01-22
Requests 是第三方模块,如果要使用的话需要导入。Requests也可以说是urllib模块的升级版,使用上更方便。
这是使用urllib的例子。
import urllib.request
import json
url = 'http://www.weather.com.cn/data/sk/101190408.html'
res = urllib.request.urlopen(url)#发送请求
result = res.read().decode()#获取结果,结果是byte类型的需要decode()
print(json.loads(result))
更多相关文章
- python打印列表的下标和值的例子:
- 面试---Python中的模块和包是什么?
- python及其模块下载集合
- python的turtle模块画折线图
- python2.7练习小例子(十二)
- centos7 安装 Python PIL模块
- Python添加默认模块搜索包路径
- python 装饰器和 functools 模块
- Python 3.x--模块导入