ua-parser-rs is a Python package that provides a native Rust accelerator for user-agent string parsing. It is not intended for direct use, but rather serves as a high-performance backend for the `ua-parser` Python library. Currently at version 0.1.5, its releases are tied to the upstream `uap-rust` project, with semi-regular updates reflecting performance improvements and bug fixes in the core Rust library.
pip install ua-parser-rsNo compatibility data collected yet for this library.
This quickstart demonstrates how to use the `ua-parser` library, which internally utilizes `ua-parser-rs` for accelerated user-agent string parsing when installed with the `[regex]` extra. `ua-parser-rs` itself does not expose a direct Python API for end-users.
Upgrade to Python 3.10 or newer. For projects dependent on specific Python versions, pin `ua-parser-rs` to `<0.1.4` (though this is not recommended as it will prevent access to performance and bug fixes).
Always interact with user-agent parsing functionality through the `ua-parser` library, ensuring `ua-parser-rs` is installed as a dependency (typically via `pip install 'ua-parser[regex]'`) to enable Rust acceleration.
Install Rustup, the official Rust toolchain installer, by following the instructions on `https://rustup.rs/`.
Use the `ua-parser` library, which automatically leverages `ua-parser-rs` if it's installed correctly: ```python from ua_parser import user_agent_parser ua_string = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36" parsed_ua = user_agent_parser.Parse(ua_string) print(parsed_ua) ```
Ensure the Rust toolchain is installed (see the fix for the `cargo` error), then attempt to reinstall `ua-parser-rs`: ```bash pip install ua-parser-rs ``` If installation issues persist, review the detailed output of the `pip install` command for more specific error messages.