Skip to content

ua-parser

556 6 16 Apache-2.0
0.18.0 (8 Jul 2023) Dec 29 2012 6.3 million (month)

ua-parser is an User-Agent header string parser for Python. It's inspired by javascript package with the same name ua-parser and performs identifcal functionality but in Python.

In web scraping, ua-parser is used in anti-scraping bypass. It helps to design user agent string rotation in scraper fingerprinting by providing consisten and reliably information about user agents.

Example Use


from ua_parser import user_agent_parser

user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.1) Gecko/20100020 Firefox/109.0"
parsed = user_agent_parser.Parse(user_agent)
print(parsed)
{
    "device": {
        "brand": "Apple", 
        "family": "Mac", 
        "model": "Mac",
    },
    "os": {
        "family": "Mac OS X",
        "major": "10",
        "minor": "15",
        "patch": None,
        "patch_minor": None,
    },
    "string": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.1) Gecko/20100020 Firefox/109.0",
    "user_agent": {
        "family": "Firefox", 
        "major": "109", 
        "minor": "0", 
        "patch": None,
    },
}

Alternatives / Similar


4,388 1.2.71 (1 year, 6 months ago) Dec 28 2012 compare

Other Languages

Was this page helpful?