7.0.1962-stable
Useragent
available since: 7.0
@library("useragent", "0.0.0");
This library contains a utility method to parse User Agent strings often stored inside web log files.
Hereafter is a simple example of usage:
@library("useragent", "0.0.0");
fn main() {
println(UserAgent::parse("Mozilla/5.0 (Linux; Android 4.4.2; QMV7A Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.135 Safari/537.36"));
}
Replace the version “0.0.0” with the appropriate one you find here. Then run
greycat install
greycat run
Output should be the following:
UserAgent{
browserFamily:"Chrome",
browserMajor:"36",
browserMinor:"0",
browserPatch:"1985",
osFamily:"Android",
osMajor:"4",
osMinor:"4",
osPatch:"2",
osPatchMinor:null,
deviceFamily:"QMV7A",
deviceBrand:"Generic_Android_Tablet",
deviceModel:"QMV7A"
}
The library parses a string containing the user agent fingerprint, and returns a UserAgent instance with the following split attributes:
browserFamily: String?: The browser name of the user agent, For example ChromebrowserMajor: String?: The browser major version, example: 36browserMinor: String?: The browser minor version, example: 0browserPatch: String?: The browser patch version version, example: 1985osFamily: String?: The OS main name, example: AndroidosMajor: String?: The OS major version, example: 4osMinor: String?: The OS minor version, example: 4osPatch: String?: The OS patch number, example: 2osPatchMinor: String?: The OS minor patch number, example: 4deviceFamily: String?: The Device name, example: iPhonedeviceBrand: String?: The Device brand, example: AppledeviceModel:String?: The Device model, example: 11