JSON

压侧工具 ngrinder 学习(发送POST JSON请求)

字号+ 作者:H5之家 来源:H5之家 2017-09-09 08:01 我要评论( )

Related Articles 压侧工具 ngrinder 学习(安装) 2016 年 12 月 8 日 ss服务搭建 翻墙 2016 年 6 月 14 日 linux下压力测试软件siege的安装与使用详解 2016 年 5 月 24 日 # -*- coding:utf-8 -*-# A simple example using the HTTP plugin that shows the r

Related Articles

压侧工具 ngrinder 学习(安装)

2016 年 12 月 8 日

ss服务搭建 翻墙

2016 年 6 月 14 日

linux下压力测试软件siege的安装与使用详解

2016 年 5 月 24 日

# -*- coding:utf-8 -*- # A simple example using the HTTP plugin that shows the retrieval of a # single page via HTTP. # # This script is automatically generated by ngrinder. # # @author admin from net.grinder.script.Grinder import grinder from net.grinder.script import Test from net.grinder.plugin.http import HTTPRequest from net.grinder.plugin.http import HTTPPluginControl from HTTPClient import NVPair #导入对JSON格式返回值的处理函数 from org.json import JSONObject import sys reload(sys) sys.setdefaultencoding('utf-8') control = HTTPPluginControl.getConnectionDefaults() # if you don't want that HTTPRequest follows the redirection, please modify the following option 0. # control.followRedirects = 1 # if you want to increase the timeout, please modify the following option. control.timeout = 6000 test1 = Test(1, "api.vd.cn") request1 = HTTPRequest() # Make any method call on request1 increase TPS test1.record(request1) class TestRunner: # initlialize a thread def __init__(self): grinder.statistics.delayReports=True pass # test method def __call__(self): headers = [ NVPair("Content-Type","application/json") ] json_data='{"is_card_photo":"1","wid":"200168668","BaseAppType":"android","BaseAppVersion":"4.4.0","SystemVersion":"4.4.2","shop_id":"11433415","_sign_":"DDFDDA37A35F2CF28591FC6D18245779","_token_":"53c571f37a7e2fe64cc4d24200fdd8ca","_wid_":"200168668","appIdentifier":"com.hs.yjseller"}' #submitdata = [NVPair("a","1"),NVPair("b","2"),NVPair("c","3")] result = request1.POST(" ip/user/getuseraddressall", json_data, headers) # You get the message body using the getText() method. # if result.getText().find("HELLO WORLD") != -1 : # grinder.statistics.forLastTest.success = 1 # else : # grinder.statistics.forLastTest.success = 0 # if you want to print out log.. Don't use print keyword. Instead, use following. #grinder.logger.info(result.getText()) if result.getStatusCode() == 200 : grinder.statistics.forLastTest.success = 1 elif result.getStatusCode() in (301, 302) : grinder.logger.warn("Warning. The response may not be correct. The response code was %d." % result.getStatusCode()) grinder.statistics.forLastTest.success = 1 else : grinder.statistics.forLastTest.success = 1

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • 学习Linux精神绝招

    学习Linux精神绝招

    2017-08-24 11:00

  • JSON学习---合并Merge,克隆Clone,指向子对象ForcePath

    JSON学习---合并Merge,克隆Clone,指向子对象ForcePath

    2017-07-15 15:01

  • JSON学习---json从XML中解析出ISuperObject

    JSON学习---json从XML中解析出ISuperObject

    2017-07-09 18:02

  • Json Format(json格式化解析工具)下载 V1.0 绿色版

    Json Format(json格式化解析工具)下载 V1.0 绿色版

    2017-06-13 13:00

网友点评
h