First, you should know:
- UserAgent can be modified, and there are historical reasons why using this field to identify browsers is somewhat unreliable, but a closer look reveals some of the patterns used to summarize the available information.
- Chrome/Safari blink/webkit IE – Trident Firfox – gecko OPERA – presto/webkit/blink
history
UserAgent was first popularized by Netscape Navigator, and subsequent browsers followed the Netscape format. For example, shortly after Netscape Navigator 3 was released, Microsoft announced its first Web browser: IE3, but Netscape was the preferred browser at the time, and most servers would check userAgent for that browser before loading pages. If IE is not compatible with the Netscape userAgent string, users using IE cannot open these pages at all, resulting in the following format: Mozilla/2.0 (compatible; MSIE 3.02; Windows 95) the result was that Internet Explorer was identified as Mozilla, disguised as Netscape Navigator, which is why most browsers today have “Mozilla/5.0” characters in the userAgent field. After the subsequent browser was born, in order to open the market, learning from IE, userAgent took a more and more similar path, it is difficult to distinguish the female.
The navigator userAgent format
Mozilla/[version] ([system and browser information]) [platform] ([platform details]) [extensions]
- Mozilla/[version] : This is already compatible, so it doesn’t make any sense. Generally Mozilla/5.0.
- ([System and browser information]) : system and browser information, such as: (Macintosh; Intel Mac OS X 10_13_6)
- [Platform] : browser rendering engine, such as AppleWebKit/537.36
- ([Platform Details]) : The browser renders additional information. This field is no longer meaningful for compatibility between browsers, such as (KHTML, like Gecko). This field also needs to be enclosed in parentheses.
- [Extensions] : indicates an extension field. These fields are the most rich in content and mainly describe the browser information and user-defined fields added by each browser. The Chrome / 70.0.3538.5 Safari / 537.36.
Note: The second field is designed to describe the browser information. Some browsers do not do this, so the browser information is recorded in the later extended fields.
Field interpretation
- Mozilla/[version]
Mozilla/5.0, Mozilla/4.0, Opera/9.80(Opera used to specify the browser name/version)
- System and browser information
The only rule is to separate the fields in parentheses with semicolons. The following fields are intercepted by the userAgent to analyze the second field:
// Windows // IE series Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1 Mozilla/4.0 (Compatible; MSIE 7.0; Windows NT 6.0) Mozilla/4.0 (Compatible; MSIE 8.0; Windows NT 6.0; Trident / 4.0) Mozilla / 5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident / 5.0) Mozilla / 5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0) Mozilla/5.0 (Compatible, MSIE 11, Windows NT 6.1; Trident / 7.0; The rv: 11.0) Mozilla / 5.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident / 4.0; KB974489; Maxthon 2.0) Mozilla / 5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident / 4.0; WOW64; Trident / 5.0; Maxthon 2.0) // Edge Mozilla/5.0 (Windows NT 6.1; WOW64) Mozilla/5.0 (Windows NT 10.0; Win64; X64) // Firefox Mozilla/5.0 (Windows NT 6.1; WOW64; Rv :40.0) Mozilla/5.0 (Windows NT 10.0; Win64; x64; Rv :61.0) // Chrome Mozilla/5.0 (Windows NT 10.0; Win64; X64) // Mac Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10; The rv: 33.0) Mozilla / 5.0 (Macintosh; Intel Mac OS X 10_9_3) // Linux Mozilla/5.0 (X11; Ubuntu; Linux i686; The rv: 18.0) Mozilla / 5.0 (X11; Linux i586; Rv :31.0) // iOS Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X U; CPU iPhone OS 4_3_3 like Mac OS X; // Android Mozilla/5.0 (Linux; U; Android 2.3.7. en-us; NexusOneBuild/FRF91) // Others Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; En) Mozilla / 5.0 (HP - tablet; Linux; HpwOS / 3.0.0; U; en-US)Copy the code
System:
field | The corresponding system |
---|---|
compatible/windows | windows |
Macintosh | mac PC |
X11/linux | linux |
iPhone/iPad/iPod | Ios mobile terminal |
Android | The android |
Other fields: Windows NT X.x
field | Corresponding to the version |
---|---|
MSIE 6.0; Windows NT 5.1 | IE6 |
MSIE 7.0; Windows NT 6.0 | IE7 |
MSIE 8.0; WindowsNT 6.0; Trident / 4.0 | IE8 |
MSIE 9.0; Windows NT 6.1; Trident / 5.0 | IE9 |
MSIE 10.0; Windows NT 6.1; WOW64; Trident / 6.0 | IE10 |
MSIE 11, Windows NT 6.1; Trident / 7.0; The rv: 11.0 | IE11 |
- Browser rendering engine
In general, the different kernels can be roughly distinguished as follows:
AppleWebKit/537.36(KHTML, like Gecko) // Generally chrome/ Safari, webkit/blink Gecko/20100101 // generally Firefox browser, The kernel is gecko Presto/2.8.131 // old version of Opera, the kernel is Presto like gecko // IE11 started to write this, it is not practical significanceCopy the code
- Extension field
The extended fields are separated by Spaces and contain important information. The mainstream fields are as follows:
Chrome: Chrome/ Version number
Safari: Safari/ version number (For historical reasons, Chrome also has Safari field at the end of the browser)
Version: Version/ Version Indicates the system Version
Mobile: Indicates the internal version number of a Mobile device. An Apple device carries the version number, but an Android device does not
It can also include other browser fields, mainly a variety of third-party browsers, H5 pages embedded in the APP, etc. In order to self-identify, it adds information unique to the APP, which helps to distinguish the end. Generally speaking, it adopts the kay/value form.
Common browser userAgent
- Chrome
Chrome/ 73.0-Win10: Mozilla/5.0 (Windows NT 10.0; Win64; X64) AppleWebKit / 537.36 (KHTML, Chrome/73.0.3683.103 Safari/537.36 Chrome 17.0 -- MAC Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11Copy the code
- Safari
Safari 5.1 -- Windows Mozilla/5.0 (Windows; U; Windows NT 6.1; En-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50 Safari 5.1 -- MAC Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; En-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50Copy the code
- The Firefox browser
Firefox 6.0 - Win7: Mozilla/5.0 (Windows NT 6.1; WOW64; Rv :6.0) Gecko/20100101 Firefox/6.0 Firefox 4.0.1 -- MAC Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; The rv: Gecko / 20100101 Firefox 2.0.1) / 4.0.1Copy the code
- The Opera browser
Opera 11.11 -- Windows User-Agent:Opera/9.80 (Windows NT 6.1; U; En) Presto/2.8.131 Version/11.11 Opera 11.11 -- MAC User-Agent:Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; En) Presto / 2.8.131 Version / 11.11Copy the code
- IE browser
IE 11 Mozilla/5.0 (Windows NT 10.0; WOW64; Trident / 7.0; Rv :11.0) like Gecko IE 9.0 Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident / 5.0; Internet explorer 8.0 Mozilla / 4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0) IE 7.0 Mozilla/4.0 (Compatible; MSIE 7.0; Windows NT 6.0) IE 6.0 Mozilla/4.0 (Compatible; MSIE 6.0; Windows NT 5.1) WinXP+ IE8: Mozilla/4.0 (Compatible; MSIE 8.0; Windows NT 5.1; Trident / 4.0; WinXP+ IE7: Mozilla/4.0 (Compatible; MSIE 7.0; Windows NT 5.1) WinXP+ IE6: Mozilla/4.0 (Compatible; MSIE 6.0; Windows NT 5.1; SV1)Copy the code
- Surf browser
Mozilla / 4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)Copy the code
- Sogou browser
Mozilla / 4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident / 4.0; SE 2. MetaSr 1.0 X; SE 2. MetaSr 1.0 X; The.net CLR 2.0.50727; SE 2. MetaSr 1.0 X)Copy the code
- 360 the browser
Mozilla / 4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)Copy the code
- 360 ultra speed browser
Mozilla / 5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36 QIHU 360EECopy the code
- QQ browser
PC Mozilla / 4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler 4.0) mobile MQQBrowser/26Mozilla/5.0 (Linux; U; Android2.3.7; zh-cn; MB200Build/GRJ22; Cyanogenmod-7) AppleWebKit/533.1(KHTML,likeGecko) Version/4.0 Mobile Safari/533.1Copy the code
- Android
Mozilla / 5.0 (Linux; U; Android2.3.7; en-us; NexusOneBuild/FRF91) AppleWebKit/533.1(KHTML,likeGecko) Version/4.0 Mobile Safari/533.1Copy the code
- iPhone
Mozilla / 5.0 (iPhone; U; CPUiPhoneOS4_3_3likeMacOSX; En-us) AppleWebKit/533.17.9(KHTML,likeGecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5Copy the code
- iPad
Mozilla / 5.0 (the device; U; CPUOS4_3_3likeMacOSX; En-us) AppleWebKit/533.17.9(KHTML,likeGecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5Copy the code
You can obtain related information from userAgent
- From the environment
The environment | field | Matching version number (osVersion) |
---|---|---|
The mobile end – Android | android | Android([\d.]+) |
The mobile end – the iPhone | iPhone | iPhoneOS([\d_]+) |
The mobile end device | iPad | OS([\d_]+) |
PC – browser | Chrome/Safari/Firefox/Opera/Windows NT/Maxthon/TencentTraveler / 360 se/QIHU 360 ee/MicroMessenger, etc | — |
Mobile browser – | MQQBrowser/ |
- Differentiate by platform
PC:
platform | Match the logo | note |
---|---|---|
Windows | Windows NT 5.1, Windows NT 6.0, Windows NT 6.0, etc | Detailed analysis of the model requires the addition of Trident |
MAC | Macintosh | |
Linux | x11; Linux PPC/ppc64 / i6886, etc |
Mobile client:
platform | Match the logo | note |
---|---|---|
Android | Android3.3.3 | |
iPhone | iPhoneOS4_3_3 | |
iPad | iPad OS4_3_3 |
PS: There is no unified and fixed format for userAgent. UserAgent can only summarize general rules. If you want to obtain relevant information, you need to know what kind of information you want in advance and then rematch it.
If there are mistakes, welcome to correct ~