Python做一个接口压测
来源:互联网 发布:双11淘宝能便宜多少 编辑:程序博客网 时间:2024/06/07 03:36
#!/usr/bin/env python
#coding=utf8
import httplib, urllib, urllib2, json,random,datetime
nowTimestyle=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
nowTime=datetime.datetime.now().strftime("%Y%m%d%H%M%S");#生成当前时间
#print nowTime
randomNum=random.randint(0,10000);#生成的随机整数n,其中0<=n<=100
if randomNum<=1000:
randomNum=str(0)+str(randomNum); #不足位用0补齐
uniqueNum=str(nowTime)+str(randomNum);
#print uniqueNum
for i in range (0,10):
def http_post():
nowTimestyle=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
nowTime=datetime.datetime.now().strftime("%Y%m%d%H%M%S");#生成当前时间
#print nowTime
randomNum=random.randint(0,1000);#生成的随机整数n,其中0<=n<=100
if randomNum<=100:
randomNum=str(0)+str(randomNum);
uniqueNum=str(nowTime)+str(randomNum);
serverurl = 'http://192.168.1.21/trade/order/reservation'
postData = {"extReservationNo" :uniqueNum,
"memberId" :"2017045000",
"reservationTime" :nowTimestyle,
"reservationAmount" :"2000.00",
"productCode" :"123456",
"saleChannel" :"2554",
"userName" :"A",
"certNo" :"41111555",
"telNo" :"151210111"}
params = json.dumps(postData,indent =4) # 对数据进行JSON格式化编码
print(params)
request = urllib2.Request(serverurl, params) # 生成页面请求的完整数据
request.add_header('Content-Type','application/json')
request.get_method = lambda:'POST' # 设置HTTP的访问方式
response = urllib2.urlopen(request) # 发送页面请求
return response.read() # 获取服务器返回的页面信息
resp = http_post()
print resp
#coding=utf8
import httplib, urllib, urllib2, json,random,datetime
nowTimestyle=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
nowTime=datetime.datetime.now().strftime("%Y%m%d%H%M%S");#生成当前时间
#print nowTime
randomNum=random.randint(0,10000);#生成的随机整数n,其中0<=n<=100
if randomNum<=1000:
randomNum=str(0)+str(randomNum); #不足位用0补齐
uniqueNum=str(nowTime)+str(randomNum);
#print uniqueNum
for i in range (0,10):
def http_post():
nowTimestyle=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
nowTime=datetime.datetime.now().strftime("%Y%m%d%H%M%S");#生成当前时间
#print nowTime
randomNum=random.randint(0,1000);#生成的随机整数n,其中0<=n<=100
if randomNum<=100:
randomNum=str(0)+str(randomNum);
uniqueNum=str(nowTime)+str(randomNum);
serverurl = 'http://192.168.1.21/trade/order/reservation'
postData = {"extReservationNo" :uniqueNum,
"memberId" :"2017045000",
"reservationTime" :nowTimestyle,
"reservationAmount" :"2000.00",
"productCode" :"123456",
"saleChannel" :"2554",
"userName" :"A",
"certNo" :"41111555",
"telNo" :"151210111"}
params = json.dumps(postData,indent =4) # 对数据进行JSON格式化编码
print(params)
request = urllib2.Request(serverurl, params) # 生成页面请求的完整数据
request.add_header('Content-Type','application/json')
request.get_method = lambda:'POST' # 设置HTTP的访问方式
response = urllib2.urlopen(request) # 发送页面请求
return response.read() # 获取服务器返回的页面信息
resp = http_post()
print resp
阅读全文
0 0
- Python做一个接口压测
- 使用python做接口测试
- 使用Python做接口测试
- Jenkins + python(requests)做接口自动化测试
- Python做接口测试生成测试报告失败
- 接口有什么好处?用接口做一个打折功能
- python-clutter做的一个立方体
- 用python做一个简易的图形界面
- 【Python】 做一个简单的 http 服务器
- 用Python做一个模板引擎玩具
- 尝试使用python做一个网页爬虫
- 做一个简单的python爬虫
- 用python做一个简单爬虫
- 用python做一个简易休息提醒
- python requests做接口测试对json的处理
- 教你做一个USB接口的室内温度计
- 如何做一个简单的开放接口(1)-功能设计
- 从今天起,做一个会写接口的人
- 配置phpStorm实现remote host远程同步开发
- Linux流量监控工具--iftop
- 【Kafka源码】KafkaController启动过程
- transform
- 使用maven加载项目中缺少的jar包
- Python做一个接口压测
- notepad正则表达式为字符串添加引号
- 游戏美术设计教程之武器的设计思路
- ReactNativeJS: Expected a component class, got [object Object].
- CentOs7安装MySQL
- 存储过程
- java工程师技能以及大数据相关技术总结
- Spring 数据加载和事务管理器配置注释详解
- Android音视频-音频播放