python简洁之道-----Requests库
来源:互联网 发布:手机淘宝有好货报名 编辑:程序博客网 时间:2024/05/16 01:23
requests是python的一个HTTP客户端库,和urllib、urllib2类似,但是urllib2的api比较复杂,比如像实现一个post或是get功能都得需要一大堆代码。
今天先简单介绍一下这个库,等我看过官方文档之后,在写一个全面一点的。
# -*- coding:utf8 -*-import requestr = requests.get('http://www.zhidaow.com')#发送请求r.status_code#返回状态码r.headers['content-type']#返回头部信息r.encoding#返回编码信息r.text#返回内容部分#各种HTTP请求r = requests.post('http://httpbin.org/post')r = requests.put('http://httpbin.org/put')r = requests.delete('http://httpbin.org/delete')r = requests.head('http://httpbin.org/get')r = requests.options('http://httpbin.org/get')#带有参数的请求例子payload = {'wd':'张亚楠','rn':'100'}r = requests.get('http://www.baidu.com/s',parama = payload)print r.url#获取json结果r = requests.get('...')r.join()['data']['country']
0 0
- python简洁之道-----Requests库
- python爬虫 - python requests网络请求简洁之道
- Python之requests库
- python库之requests
- python学习之 requests库
- Python学习之Requests库
- Python网络爬虫之Requests库
- Python库之Requests(iMooc)---(1)
- Python库之Requests(iMooc)---(2)
- Python库之Requests(iMooc)---(3)
- Python库之Requests(iMooc)---(4)
- Python库之Requests(iMooc)---(5)
- Python爬虫之requests
- python之requests篇
- Python之,requests包
- python爬虫之requests
- python requests库 笔记
- python requests库介绍
- TTL与RS-232电平转换芯片MAX232/MAX3232
- Active Report 导出功能
- 阿里云上安装phpMyAdmin
- 前端测试系列---如何核对需求
- asp.net 用户控件中的委托事件SelectedIndexChanged
- python简洁之道-----Requests库
- hdu 1874 畅通工程续
- IOS同步请求和异步请求的区别
- 安卓入门学习之ListView
- JSON字符串和JSON对像相互转化
- nio client和netty server实例
- 【数据结构】回顾表、栈、队列
- android图文列表
- cocos2d-x 游戏暂停界面,监听home键,返回键,Menu键 解决方案