locust -post請求


------------恢復內容開始------------

參考:https://www.cnblogs.com/imyalost/p/9758189.html

#coding=utf-8
import requests
from locust import HttpLocust,TaskSet,task
class Msg(TaskSet):

@task(1)
def get_blog(self):

header = { "Content-Type":"application/json"}
payload={
"data": "{\"phone\":\"7029876553\",:\"message's body\",\"action\":\"https://www.baidu.com\"}",
"appId": 1,
"sign": "d9347eb257a0",
"id": "500",
"packageName": "team.xxx.pay",
"body": "message's body",
"businessType": "pay",
"list": ["7029876123213553","702912312876554","7020981231236549"],
"title": "test11:06--message's title",
"operator": "1"
}



req = self.client.post("/push/push",data=payload ,headers=header, verify=False)
if req.status_code == 200:
print("success")
else:
print("fails")


class websitUser(HttpLocust):
task_set = Msg
min_wait = 1000 # 單位為毫秒
max_wait = 3000 # 單位為毫秒


if __name__ == "__main__":
import os

os.system("locust -f locust_api.py --host=http://dev.xxx.com")

------------恢復內容結束------------


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM