Lua 刷http请求
lua刷请求:
local http = require("socket.http")
local ltn12 = require("ltn12")
function http.get(u)
local t = {}
local r, c, h = http.request{
url = u,
sink = ltn12.sink.table(t)
}
return r, c, h, table.concat(t)
end
urls={
"https://www.baidu.com/";
"https://www.baidu.com/";
}
math.randomseed(tostring(os.time()):reverse():sub(1, 6))
for i=0,10000000 do
local index=math.random(9)
print(index,"...",i)
local r,c,h,body=http.get(urls[index])
end
body为请求返回内容。
既已览卷至此,何不品评一二: