爬虫之 requests小结
来源:互联网 发布:大型网络枪战游戏 编辑:程序博客网 时间:2024/06/05 09:50
文档
English – http://www.python-requests.org/en/master/
中文 – http://cn.python-requests.org/zh_CN/latest/
快速上手– http://docs.python-requests.org/zh_CN/latest/user/quickstart.html
高级用法 – http://cn.python-requests.org/zh_CN/latest/user/advanced.html
源码
http://cn.python-requests.org/zh_CN/latest/user/install.html#id2
Requests 支持 Python 2.6—3.5,而且能在PyPy下完美运行。
import requestsr = requests.get(url) # r 是response的对象r = requests.post(url, data = post_data) # 提交表单 字典类型的表单数据r = requests.get(url, headers=headers) # headers 字典类型的请求头r = requests.get(url, cookies=cookies) # 带cookies的请求r = requests.get("http://example.org", proxies=proxies) # 通过代理请求proxies = { "http": "http://10.10.1.10:3128", "https": "http://10.10.1.10:1080",}r.text # 得到页面文本的内容 Unicode型的数据r.encoding # 网页的编码 可以设置如 r.encoding = 'utf-8'r.content # bytes型也就是二进制的数据, 想取图片,文件,则可以通过r.contentr.status_code # 状态码r.headers # 服务器返回的响应头r.cookies # cookiesr.request.headers # 发送到服务器的请求头requests.get('http://github.com', timeout=0.001) # timeout 设置超时时间r.json() # 内置json解码器s = requests.Session() # 保持cookie 如保持登陆状态具体用法 看文档
阅读全文
0 0
- 爬虫之 requests小结
- Python爬虫之requests
- python爬虫之requests
- Python爬虫工具之Requests
- Python爬虫之requests介绍
- Python爬虫大杀器之Requests快速入门
- 从零开始学网络爬虫之Requests库
- 爬虫系列之Requests库入门
- Python网络爬虫之Requests库
- Python爬虫Requests模块系列之六
- Pythoon爬虫之requests库学习
- 爬虫实战之五--requests详解
- python3爬虫初探(二)之requests
- 1、网络爬虫之规则之requests库入门
- python爬虫 - python requests网络请求简洁之道
- Python爬虫利器一之Requests库的用法
- python学习之 requests爬虫导致的中文乱码
- Python爬虫利器一之Requests库的用法
- for和for in的区别
- 批量解压rar文件中指定类型的文件
- eclipse paho包对于ActiveMQ持久化订阅者的设置
- 顺序表
- js 点击事件,出现背景颜色
- 爬虫之 requests小结
- 会议室预约系统-乐享其约-微信预约
- Spring WebSocket实现消息推送
- JXplorer的简单使用
- C++虚函数及其应用
- 计蒜之道初赛第一场-阿里天池的新任务(简单)
- Convert BST to Greater Tree
- 廖雪峰的Git教程一(创建版本库)
- webpack之css-loader