前言
UserAgent作为客户端与服务器之间交互的重要标识,对于了解用户设备信息、优化用户体验以及网站或应用的兼容性测试等方面都具有重要的意义。通过解析不同的UserAgent,我们可以更好地理解用户的需求和习惯,提供更个性化、优质的服务。随着移动互联网的普及和技术的不断进步,UserAgent的解析和识别将在未来的应用中发挥更大的作用。
使用
微信浏览器的UserAgent通常包含“MicroMessenger”这一关键词
下面是一个识别如果是微信客户端的浏览器,则自动跳转到默认浏览器的代码
const userAgent = navigator.userAgent.toLowerCase()
if (userAgent.indexOf('micromessenger') !== -1) {
const url = `http://www.iot2ai.top/cgi-bin/wxit/open.html?${window.location.href}`
alert(url)
window.location.href = url
}
常见 User-Agent
浏览器 | 设备 | UserAgent |
---|---|---|
微信内置浏览器 | MacOS | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 NetType/WIFI MicroMessenger/6.8.0(0x16080000) MacWechat/3.8.6(0x13080611) XWEB/1152 Flue |
微信内置浏览器 | Windows | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x63090819) XWEB/8519 Flue |
微信内置浏览器 | Android | Mozilla/5.0 (Linux; Android 13; 22081212C Build/TKQ1.220829.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Mobile Safari/537.36 XWEB/1160043 MMWEBSDK/20231105 MMWEBID/4478 MicroMessenger/8.0.44.2502(0x28002C51) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 |
微信小程序请求 | Android | Mozilla/5.0 (Linux; Android 13; 22081212C Build/TKQ1.220829.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Mobile Safari/537.36 XWEB/1160043 MMWEBSDK/20231105 MMWEBID/4478 MicroMessenger/8.0.44.2502(0x28002C51) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android |
微信小程序WebView | Android | Mozilla/5.0 (Linux; Android 13; 22081212C Build/TKQ1.220829.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Mobile Safari/537.36 XWEB/1160043 MMWEBSDK/20231105 MMWEBID/4478 MicroMessenger/8.0.44.2502(0x28002C51) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 miniProgram/wxdec51c0e2b06cbfe |
支付宝内置浏览器 | Android | Mozilla/5.0 (Linux; Android 13; 22081212C Build/TKQ1.220829.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/105.0.5195.148 MYWeb/0.11.0.231220162319 UWS/3.22.2.9999 UCBS/3.22.2.9999_220000000000 Mobile Safari/537.36 NebulaSDK/1.8.100112 Nebula AlipayDefined(nt:WIFI,ws:407 |
抖音内置浏览器 | Android | Mozilla/5.0 (Linux; Android 10; HD1900 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.156 Mobile Safari/537.36 aweme_230400 JsSdk/1.0 NetType/WIFI AppName/aweme app_version/23.4.0 ByteLocale/zh-CN Region/CN AppSkin/white AppTheme/light BytedanceWebview/d8a21c6 WebView/075113004008 |
QQ内置浏览器 | Android | Mozilla/5.0 (Linux; Android 13; 22081212C Build/TKQ1.220829.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/109.0.5414.86 MQQBrowser/6.2 TBS/046905 Mobile Safari/537.36 V1_AND_SQ_9.0.0_5282_YYB_D PA QQ/9.0.0.14110 NetType/WIFI WebP/0.3.0 AppId/537194356 Pixel/1220 StatusBarHeight/89 SimpleUISwitch/1 QQTheme/2971 StudyMode/0 CurrentMode/1 CurrentFontScale/1.0 GlobalDensityScale/1.0166667 AllowLandscape/false InMagicWin/0 |
B站客户端 | MacOS | Mozilla/5.0 (iPad; CPU OS 16_6 like Mac OS X) AppleWebKit/615.3.12.11.2 (KHTML, like Gecko) Mobile/22G90 BiliApp/36601100 os/ios model/iPad Pro 12.9-Inch 3G mobi_app/ipad build/36601100 osVer/16.6 network/2 channel/AppStore Buvid/Y65AF76CD250F2FD5D938E938DAD17C8C306 c_locale/zh-Hans_CN s_locale/zh-Hans_CH sessionID/a95eff62 disable_rcmd/0 |
Chrome | MacOS | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 |
Chrome | Windows | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 |
Chrome | Android | Mozilla/5.0 (Linux; Android 6.0.1; SOV33 Build/35.0.D.0.326) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.91 Mobile Safari/537.36 |
Safari | iOS | Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Mobile/15E148 Safari/604.1 |