lua解析UserAgent
来源:互联网 发布:曲谱制作软件 编辑:程序博客网 时间:2024/05/22 11:39
--解析UserAgent,获取移动设备访问的系统版本和设备型号
function getUAField(t)
local separator=';'
local tab={}
local android=string.find(t,"Android")
local iphone=string.find(t,"iPhone")
if android then
tab["platform"]="android"
local startIndex =string.find(t,"Build")
if startIndex ~= nil then
local res=string.sub(t,0,startIndex-1)
local rtable=string.split(res,separator)
local devicename=string.trim(rtable[#rtable])
if devicename~=nil then
tab["devicename"]=devicename
end
end
local osvTable=string.split(string.sub(t,android) ,separator)
if osvTable then
local osvTab=string.split(osvTable[1] ,' ')
tab["os_version"]=string.trim(osvTab[#osvTab])
end
end
if iphone then
tab["platform"]="iOS"
tab["devicename"]="iphone"
local vs=string.find(t,"Version")
local osvTable=string.split(string.sub(t, vs) ,' ')
if osvTable then
print(osvTable[1])
local osvTab=string.split(osvTable[1] ,'/')
tab["os_version"]=string.trim(osvTab[#osvTab])
end
end
if next(tab) == nil then
tab["platform"]=""
tab["devicename"]=""
tab["os_version"]=""
end
return tab
end
0 0
- lua解析UserAgent
- lua+nginx解析useragent实例
- UserAgent
- userAgent
- userAgent
- Hive自定义函数的使用——useragent解析
- Request.UserAgent信息解析,js获取客户端操作系统
- lua 源代码解析
- Lua初学常见问题解析
- lua源代码解析
- Lua解析文件MD5
- cocos2dx lua json解析
- lua 解析url
- Lua解析1 TValue
- lua 源代码解析
- lua 标签解析器
- lua 标签解析器
- lua-proto动态解析
- selenium-webdriver(python) (十)
- This Android SDK requires And...e ADT to the latest version.
- Android Studio Exception: Could not find method android() for arguments
- Android自定义View绘图基础(摘自技术前沿)
- jsp页面EL表达式不被解析的解决方法
- lua解析UserAgent
- 神经网络误差反向传播
- iOS10的适配总结(转)
- 如何估算网站日承受最大访问PV
- java mybatis XML文件中大于号小于号转义
- app开发外包注意事项,2017最新资讯
- 【Unity】像素图片导入批处理
- 分布式服务的事务如何处理
- HDU1257——最少拦截系统(贪心)