lua打开浏览器并加载网页_Lua脚本解析web端发送的数据与浏览器的useragent

local cjson = require("cjson")

local cjson_safe = require("cjson.safe")

local logger = require("logger")

local uuid4= require("uuid4")

local args = {}

local request_method = ngx.var.request_method

function string.split(str, delimiter)

if str==nil or str=='' or delimiter==nil then

return nil

end

local result = {}

for match in (str..delimiter):gmatch("(.-)"..delimiter) do

table.insert(result, match)

end

return result

end

function string.trim (s) return (string.gsub(s, "^%s*(.-)%s*$", "%1")) end

function getUAField(t)

local separator=';'

local tab={}

local android=string.find(t,"Android")

local iphone=string.find(t,"Mac")

local windows=string.find(t,"Windows")

--android手机

if android then

tab["platform"]="android"

-- tab["number"]=android

tab["ismobiledevice"]="true"

local startIndex =string.find(t,"Build")

if startIndex then

local res=string.sub(t,0,startIndex-1)

local rtable=string.split(res,separator)

local devicename=string.trim(rtable[#rtable])

local name=string.find(t,"XiaoMi")

if name then

local name1 = string.sub(t,name,name+6)

tab["number"]=name

if devicename~=nil then

tab["devicename"]=name1 .. "/" .. devicename

end

else

if devicename~=nil then

tab["devicename"]=devicename

end

end

end

local osvTable=string.split(string.sub(t,android) ,separator)

if osvTable then

local osvTab

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值