python http客户端(requests)
来源:互联网 发布:数据采集系统解决方案 编辑:程序博客网 时间:2024/05/01 14:13
httpclient发送json对象
在header中要注明发送的内容'Content-Type' : 'application/json;charset=UTF-8',
dictHeaders = {'Accept':'application/json, text/plain, */*',
'Accept-Language' : 'zh-CN',
'Content-Type' : 'application/json;charset=UTF-8',
#'Content-Type' : 'application/x-www-form-urlencoded',
#'Accept-Encoding' : 'deflate',
'Connection' : 'Keep-Alive',
'User-Agent' : 'Mozilla/5.0 compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0',
#'User-Agent': 'Mozilla/4.0 compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E',
#'Referer': 'https://pbsz.ebank.cmbchina.com/CmbBank_CreditCardV2/UI/CreditCardPC/CreditCardV2_AccountManager/am_QueryReckoningSurveyNew.aspx',
'Pragma': 'no-cache'}
requests使用
class HttpTest(ApiBase):
def POST(self):
self.auth_or_redirect()
kwargs = utils.get_body_object()
resp = requests.request(**kwargs)
result = {
'status': resp.status_code,
'data': resp.content,
'headers': dict(resp.headers.items())
}
return json.dumps(result, ensure_ascii=False)
{"url":"http://api.sit.ffan.com/basicservice/v1/developers","method":"POST","params":"develop_id=C00000000001&develop_key=3a8253b975148c428f09c329666a4134","json":{"developer_name":"ffan","bizId":"1001001001"}}
request设置代理:
kwargs = {'url' : strUrl,
'method' : 'GET',
'params' : dictParams,
'headers': {},
'proxies': {"http":"http://用户名:密码@IP:端口/"}
}
- python http客户端(requests)
- python requests请求http
- Python HTTP库requests 介绍
- Python requests实现HTTP请求
- python http请求工具Requests
- Python 第三方 http 库-Requests 学习
- python发送http请求之requests模块
- Python 第三方 http 库-Requests 学习
- python利用requests框架 http请求
- Python 第三方 http 库-Requests 学习
- python的http请求模块urllib+requests
- python HTTP请求--requests 的使用
- Python爬虫:HTTP协议、Requests库
- python发送http请求之requests模块
- Python使用requests提交HTTP表单
- python发送http请求之requests模块
- requests模块--python发送http请求
- python requests
- 图像识别技术——验证码识别
- 一次生产事故的优化经历
- 奖金(类拓扑排序)
- 大数据分析配置文件
- 用Python将统计数据不存在的记录按维度对应指标补齐(续:日数据情形)
- python http客户端(requests)
- spring配置文件详解--真的蛮详细
- Android 测试方式、思路
- 83.hdu--2570--迷瘴
- 【Java并发编程实战】-----“J.U.C”:锁,lock
- 基于VM10+Win7安装Mac OSX10.11 El Capitan
- 【Java并发编程实战】-----“J.U.C”:ReentrantLock之一简介
- Android Drawable之LayerDrawable
- CentOS 7实战Kubernetes部署