UA-Extract – Easy way to keep user-agent parsing updated

Simplify User Agent Detection and Stay Up-to-Date with UA-Extract

In today’s world of diverse devices and browsers, maintaining accurate user agent parsing can be a daunting task. Thatโ€™s why Iโ€™m excited to introduce UA-Extract, a Python library designed to streamline the process of identifying browsers, operating systems, and devices with minimal effortโ€”and even simpler regex updates.

What Is UA-Extract?

UA-Extract is a high-performance Python tool that easily interprets user agent strings, enabling developers to accurately detect device typesโ€”from smartphones and tablets to smart TVs and gaming consoles. Built upon the robust device_detector library, it leverages an extensive, actively maintained database of user agent patterns to handle the widest range of devices and browsers, including some of the most obscure.

Key Features and Benefits

  • Automatic Regex Refreshing:
    One of the standout capabilities of UA-Extract is its straightforward method for keeping device detection patterns current. When new devices or browsers launch, outdated regexes can lead to misclassification. UA-Extract simplifies this by allowing you to update detection patterns with a simple line of code or a command-line operationโ€”fetching the latest version directly from the trusted Matomo Device Detector project.

Example code snippet:
python
from ua_extract import Regexes
Regexes().update_regexes() # Fetch latest regex patterns

Or via CLI:
ua_extract update_regexes

  • Detailed User Agent Parsing:
    Extract comprehensive data from user agents, like OS name, device model, or secondary client applications:
    “`python
    from ua_extract import DeviceDetector

ua_string = ‘Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16D57 EtsyInc/5.22 rv:52200.62.0’
detector = DeviceDetector(ua_string).parse()
print(detector.os_name()) # e.g., iOS
print(detector.device_model()) # e.g., iPhone
print(detector.secondary_client_name()) # e.g., EtsyInc
“`

  • Optimized Performance:
    The library supports in-memory caching and uses the regex module for faster processing

Leave a Reply

Your email address will not be published. Required fields are marked *