WRK的使用-lua脚本GET请求

原理:在脚本开始之前将准备好的数据添加至数组内,每次请求根据顺序调用

wrk.method = "GET"

-- 循环列表

local queries = { -- API与参数

"/app/getConDetails?ConttId=38163230&Type=2",

"/app/getContDetails?ContId=381667330&Type=1",

}

local i = 0

request = function() –每次调用不同的接口数据

local path = wrk.format(nil, queries[i % #queries + 1])

i = i + 1

print(path)

return path

end

原理:在脚本开始之前将准备好的数据添加至数组内,每次请求根据顺序调用 wrk.method = "GET" -- 循环列表 local queries = { -- API与参数 "/app/getConDetails?ConttId=38163230&Type=2", "/app/getContDetails?ContId=381667330&Type=1", } local i = 0 request = function() –每次调用不同的接口数据 local path = wrk.format(nil, queries[i % #queries + 1]) i = i + 1 print(path) return path end
经验分享 程序员 微信小程序 职场和发展