DeviceDetector is a precise and fast user agent parser and device detector for Python, backed by a large and frequently updated user agent database. It parses any user agent string to detect the browser, operating system, device used (desktop, tablet, mobile, TV, etc.), brand, and model. Optimized for speed through efficient code and in-memory caching, the library is currently at version 6.2.0 and maintains an active release cadence, primarily updating to incorporate upstream detection rules from the Matomo project.
pip install device_detectorVerified import paths — ran on the pinned version, not inferred.
Initializes `DeviceDetector` with a user agent string, parses it, and demonstrates how to access various detected properties like OS, device type, brand, and browser.
Consult the Python library's documentation and examples for specific method names and return types.
Install `pyyaml` (with C extension support) and `mrab`: `pip install pyyaml mrab`.
Keep the library updated to benefit from the latest upstream detection rules. Monitor upstream project changes for potential impacts.
Install the library using pip: `pip install device_detector`
Ensure that `device_detector_instance.parse()` is called before accessing any detection results. Example: `device = DeviceDetector(ua).parse()`.
Ensure the user agent string is correctly encoded. If the origin encoding is known (e.g., 'latin-1', 'windows-1252'), decode it before passing to DeviceDetector, or try to sanitize problematic characters if encoding is unknown.