User-Agent是HTTP请求头中的一部分,用于标识发送请求的用户代理(通常是浏览器)。生成User-Agent的规则通常包括以下内容:
‘Mozilla/5.0 (Linux; Android 10; CDY-AN90 Build/HUAWEICDY-AN90; 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.15_0_RDM_B QQ/9.0.15.315192 NetType/WIFI WebP/0.3.0 AppId/537201424 Pixel/1080 StatusBarHeight/108 SimpleUISwitch/0 QQTheme/1000 StudyMode/0 CurrentMode/0 CurrentFontScale/1.0 GlobalDensityScale/0.90000004 AllowLandscape/false InMagicWin/0 EnableQUICheck/0’
user-agent的信息中每一个分别代表什么含义?
以下是您提供的用户代理字符串的细分:
以上的信息虽然不能都搞明白,但是我们可以通过第2条信息知道,这里是关于操作系统的能力;
‘Mozilla/5.0 (Linux; Android 8.0.0; BKL-AL20 Build/HUAWEIBKL-AL20; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.116 Mobile Safari/537.36 V1_AND_SQ_9.0.15_0_RDM_B QQ/9.0.15.315259 NetType/WIFI WebP/0.4.1 AppId/537201424 Pixel/1080 StatusBarHeight/73 SimpleUISwitch/0 QQTheme/1000 StudyMode/0 CurrentMode/0 CurrentFontScale/1.0 GlobalDensityScale/0.90000004 AllowLandscape/false InMagicWin/0 EnableQUICheck/0’
荣耀V10
‘Mozilla/5.0 (Linux; Android 10; PACM00 Build/QP1A.190711.020; 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.15_0_RDM_B QQ/9.0.15.90707 NetType/WIFI WebP/0.3.0 AppId/537201424 Pixel/1080 StatusBarHeight/97 SimpleUISwitch/0 QQTheme/1000 StudyMode/0 CurrentMode/0 CurrentFontScale/1.0 GlobalDensityScale/0.90000004 AllowLandscape/false InMagicWin/0 EnableQUICheck/0’
OPPO R15
HONOR 30S
Mozilla/5.0 (Linux; Android 10; CDY-AN90 Build/HUAWEICDY-AN90; 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.15_0_RDM_B QQ/9.0.15.315192 NetType/WIFI WebP/0.3.0 AppId/537201424 Pixel/1080 StatusBarHeight/108 SimpleUISwitch/0 QQTheme/1000 StudyMode/0 CurrentMode/0 CurrentFontScale/1.0 GlobalDensityScale/0.90000004 AllowLandscape/false InMagicWin/0 EnableQUICheck/0
iphone8plus
‘Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 QQ/9.0.15.62754_8a610f26eee_01-10_07:38_CheckIn V1_IPH_SQ_9.0.15_0_RDM_R Pixel/1080 MiniAppEnable SimpleUISwitch/0 StudyMode/0 CurrentMode/0 CurrentFontScale/1.000000 QQTheme/1000 AppId/537200874 EnableQUICheck/0 Core/WKWebView Device/Apple(iPhone 8Plus) NetType/WIFI QBWebViewType/1 WKType/1’
苹果的暂不清楚关于系统如何识别,但有后缀Device/Apple(iPhone 8Plus)
可以尝试从这个角度进行机型识别;实际上,任何一个互联网公司都有一套识别不同机型,确认机型占比的上报记录,有一套识别机型的规范,具体细节没有了解到,如果你能拿到这个信息就更好了。
还有一个npm包,device-detect,但是感觉并不难给出具体机型;