C#实现-浏览器UA解析获得手机、系统、浏览器等信息
nuget包名:toolbox.useragentparse
使用教程:
1.
打开项目→选择依赖项(引用)→右键 管理nuget程序包
2.
搜索包 toolbox.useragentparse → 找到图中的包→点击右边的安装 安装成功即可
3.调用
1 var uainfo = new uaunit(ua).parse();//实例化工具类 传入ua字符串 调用parse()方法 即可解析 2 console.writeline($"{count}.浏览器内核:{ua.browserkernel}\r\n浏览器名称:{ua.browsername}\r\n浏览器版本:{ua.browserversion}\r\n手机型号:{ua.phonemodelname}\r\n手机型号代码:{ua.phonemodelcode}\r\n平台:{ua.platform}\r\n操作系统:{ua.systemname}\r\n操作系统版本:{ua.systemversion}\r\n");
效果:
测试使用ua字符串
mozilla/5.0 (iphone; cpu iphone os 12_1_4 like mac os x) applewebkit/605.1.15 (khtml, like gecko) mobile/16d57 micromessenger/7.0.8(0x17000820) nettype/wifi language/zh_cn
mozilla/5.0 (linux; android 10; yal-al00 build/huaweiyal-al00; wv) applewebkit/537.36 (khtml, like gecko) version/4.0 chrome/66.0.3359.126 mqqbrowser/6.2 tbs/045118 mobile safari/537.36 mmwebid/9661 micromessenger/7.0.11.1600(0x27000b32) process/tools nettype/wifi language/zh_cn abi/arm64
mozilla/5.0 (linux; android 10; lya-al00p build/huaweilya-al00p; wv) applewebkit/537.36 (khtml, like gecko) version/4.0 chrome/66.0.3359.126 mqqbrowser/6.2 tbs/045118 mobile safari/537.36 mmwebid/3630 micromessenger/7.0.11.1600(0x27000b32) process/tools nettype/4g language/zh_cn abi/arm64
mozilla/5.0 (linux; android 10; lio-an00 build/huaweilio-an00; wv) applewebkit/537.36 (khtml, like gecko) version/4.0 chrome/66.0.3359.126 mqqbrowser/6.2 tbs/045118 mobile safari/537.36 mmwebid/7828 micromessenger/7.0.11.1600(0x27000b32) process/tools nettype/wifi language/zh_cn abi/arm64
mozilla/5.0 (iphone; cpu iphone os 13_0 like mac os x) applewebkit/605.1.15 (khtml, like gecko) mobile/15e148 micromessenger/7.0.11(0x17000b21) nettype/4g language/zh_cn
具体实现参考github代码 点击进入github项目
介绍就到这里,如写的有误或者有大佬有更好的实现方式 请留言指正、指导
谢谢大家