| Crates.io | simple-useragent |
| lib.rs | simple-useragent |
| version | 0.1.2 |
| created_at | 2025-02-04 07:08:05.025696+00 |
| updated_at | 2025-02-11 18:36:04.912732+00 |
| description | A simple user agent parser library based on the uap-core regexes |
| homepage | https://github.com/bplaat/crates/tree/master/lib/simple-useragent |
| repository | https://github.com/bplaat/crates |
| max_upload_size | |
| id | 1541609 |
| size | 92,690 |
A simple user agent parser library based on the uap-core regexes
A simple example that parses a user agent string and reads the parsed fields:
fn main() {
// Create a user agent parser
let parser = simple_useragent::UserAgentParser::new();
// Parse a user agent string
let ua = parser.parse(
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:134.0) Gecko/20100101 Firefox/134.0",
);
// Print the parsed user agent fields
println!("Client family: {}", ua.client.family); // -> "Firefox"
println!("Client version: {:?}", ua.client.version); // -> Some("134.0")
println!("OS family: {}", ua.os.family); // -> "Mac OS X"
println!("OS version: {:?}", ua.os.version); // -> Some("10.15")
}
See the documentation for more information.
Copyright © 2024-2025 Bastiaan van der Plaat
Licensed under the MIT license.