ua-parser-py


Nameua-parser-py JSON
Version 1.0.37 PyPI version JSON
download
home_pagehttps://github.com/vitalibo/ua-parser-py
SummaryPython library to detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data
upload_time2024-03-31 03:47:06
maintainerNone
docs_urlNone
authorVitaliy Boyarsky
requires_python>=3.6
licenseMIT
keywords user-agent parser browser engine os device cpu
VCS
bugtrack_url
requirements pytest setuptools wheel twine
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # UAParser.py

fork of [UAParser.js](https://github.com/faisalman/ua-parser-js)

![status](https://github.com/vitalibo/ua-parser-py/actions/workflows/ci.yaml/badge.svg)

Python library to detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data.

# Documentation

## Installation

```sh
pip install ua-parser-py
```

## Constructor

* `UAParser([uastring])`
    * returns new instance

* `UAParser.parse([uastring])`
    * returns result object `{ 'ua': '', 'browser': {}, 'cpu': {}, 'device': {}, 'engine': {}, 'os': {} }`

## Properties

* `browser`
    * returns `{ 'name': '', 'version': '' }`

```sh
# Possible 'browser.name':
2345Explorer, 360 Browser, Alipay, Amaya, Android Browser, Arora, Avant, Avast, 
AVG, Baidu, Basilisk, Blazer, Bolt, Brave, Bowser, Camino, Chimera,
Chrome Headless, Chrome WebView, Chrome, Chromium, Cobalt, Comodo Dragon, Dillo,
Dolphin, Doris, DuckDuckGo, Edge, Electron, Epiphany, Facebook, Falkon, Fennec, 
Firebird, Firefox [Focus/Reality], Flock, Flow, GSA, GoBrowser, Heytap, 
Huawei Browser, iCab, ICE Browser, IE, IEMobile, IceApe, IceCat, IceDragon, 
Iceweasel, Instagram, Iridium, Iron, Jasmine, Kakao[Story/Talk], K-Meleon, 
Kindle, Klar, Klarna, Konqueror, LBBROWSER, Line, LinkedIn, Links, Lunascape, 
Lynx, MIUI Browser, Maemo, Maxthon, Midori, Minimo, Mobile Safari, Mosaic, 
Mozilla, NetFront, NetSurf, Netfront, Netscape, NokiaBrowser, Obigo, 
Oculus Browser, OmniWeb, Opera Coast, Opera [Mini/Mobi/Tablet], PaleMoon, 
PhantomJS, Phoenix, Polaris, Puffin, QQ, QQBrowser, QQBrowserLite, Quark, 
QupZilla, RockMelt, Safari, Sailfish Browser, Samsung Internet, SeaMonkey, Silk, 
Skyfire, Sleipnir, Slim, SlimBrowser, Smart Lenovo Browser, Snapchat, 
Sogou [Explorer/Mobile], Swiftfox, Tesla, TikTok, Tizen Browser, UCBrowser, 
UP.Browser, Viera, Vivaldi, Vivo Browser, Waterfox, WeChat, Weibo, Yandex, w3m, 
Whale Browser, ...

# 'browser.version' determined dynamically
```

* `device`
    * returns `{ 'model': '', 'type': '', 'vendor': '' }`

```sh
# Possible 'device.type':
console, mobile, tablet, smarttv, wearable, embedded

##########
# NOTE: 'desktop' is not a possible device type. 
# UAParser only reports info directly available from the UA string, which is not the case for 'desktop' device type.
# If you wish to detect desktop devices, you must handle the needed logic yourself.
# You can read more about it in this issue: https://github.com/faisalman/ua-parser-js/issues/182
##########

# Possible 'device.vendor':
Acer, Alcatel, Amazon, Apple, Archos, ASUS, AT&T, BenQ, BlackBerry, Dell,
Essential, Facebook, Fairphone, GeeksPhone, Google, HP, HTC, Huawei, Infinix, 
Jolla, Kobo, Lenovo, LG, Meizu, Microsoft, Motorola, Nexian, Nintendo, Nokia, 
Nvidia, OnePlus, OPPO, Ouya, Palm, Panasonic, Pebble, Polytron, Realme, RIM, 
Roku, Samsung, Sharp, Siemens, Sony[Ericsson], Sprint, Tecno, Tesla, Ulefone, 
Vivo, Vodafone, Xbox, Xiaomi, Zebra, ZTE, ...

# 'device.model' determined dynamically
```

* `engine`
    * returns `{ 'name': '', 'version': '' }`

```sh
# Possible 'engine.name'
Amaya, Blink, EdgeHTML, Flow, Gecko, Goanna, iCab, KHTML, LibWeb, Links, Lynx, 
NetFront, NetSurf, Presto, Tasman, Trident, w3m, WebKit

# 'engine.version' determined dynamically
```

* `os`
    * returns `{ 'name': '', 'version': '' }`

```sh
# Possible 'os.name'
AIX, Amiga OS, Android[-x86], Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS,
Contiki, Fedora, Firefox OS, FreeBSD, Debian, Deepin, DragonFly, elementary OS, 
Fuchsia, Gentoo, GhostBSD, GNU, Haiku, HarmonyOS, HP-UX, Hurd, iOS, Joli, KaiOS, 
Linpus, Linspire,Linux, Mac OS, Maemo, Mageia, Mandriva, Manjaro, MeeGo, Minix, 
Mint, Morph OS, NetBSD, NetRange, NetTV, Nintendo, OpenBSD, OpenVMS, OS/2, Palm, 
PC-BSD, PCLinuxOS, Plan9, PlayStation, QNX, Raspbian, RedHat, RIM Tablet OS, 
RISC OS, Sabayon, Sailfish, SerenityOS, Series40, Slackware, Solaris, SUSE, 
Symbian, Tizen, Ubuntu, Unix, VectorLinux, Viera, watchOS, WebOS, 
Windows [Phone/Mobile], Zenwalk, ...

# 'os.version' determined dynamically
```

* `cpu`
    * returns `{ 'architecture': '' }`

```sh
# Possible 'cpu.architecture'
68k, amd64, arm[64/hf], avr, ia[32/64], irix[64], mips[64], pa-risc, ppc, 
sparc[64]
```

* `ua`
    * returns UA string of current instance

# Usage

```python3
import json
from uaparser import UAParser

uastring1 = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2'
result = UAParser(uastring1)

print(result.browser)  # {'name': 'Chromium', 'version': '15.0.874.106', 'major': '15'}
print(result.device)  # {'vendor': None, 'model': None, 'type': None}
print(result.os)  # {'name': 'Ubuntu', 'version': '11.10'}
print(result.os['version'])  # '11.10'
print(result.engine['name'])  # 'WebKit'
print(result.cpu['architecture'])  # 'amd64'

uastring2 = 'Mozilla/5.0 (compatible; Konqueror/4.1; OpenBSD) KHTML/4.1.4 (like Gecko)'
result = UAParser.parse(uastring2)

print(result['browser']['name'])  # 'Konqueror
print(result['os'])  # {'name': 'OpenBSD', 'version': None}
print(result['engine'])  # {'name': 'KHTML', 'version': '4.1.4'}

uastring3 = 'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.11 (KHTML, like Gecko) Version/7.1.0.7 Safari/534.11'
result = UAParser.parse(uastring3)

print(json.dumps(result, indent=4))
# {
#   "ua": "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.11 (KHTML, like Gecko) Version/7.1.0.7 Safari/534.11",
#   "browser": {
#     "name": "Safari",
#     "version": "7.1.0.7",
#     "major": "7" // @deprecated
#   },
#   "cpu": {
#     "architecture": null
#   },
#   "device": {
#     "vendor": "RIM",
#     "model": "PlayBook",
#     "type": "tablet"
#   },
#   "engine": {
#     "name": "WebKit",
#     "version": "534.11"
#   },
#   "os": {
#     "name": "RIM Tablet OS",
#     "version": "1.0.0"
#   }
# }
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/vitalibo/ua-parser-py",
    "name": "ua-parser-py",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "user-agent parser browser engine os device cpu",
    "author": "Vitaliy Boyarsky",
    "author_email": "boyarsky.vitaliy@live.com",
    "download_url": "https://files.pythonhosted.org/packages/3b/67/dfe240aa0ab1e444986e1cef8d304dea2cf1a8389cd04710e3d0af1deab8/ua-parser-py-1.0.37.tar.gz",
    "platform": "any",
    "description": "# UAParser.py\n\nfork of [UAParser.js](https://github.com/faisalman/ua-parser-js)\n\n![status](https://github.com/vitalibo/ua-parser-py/actions/workflows/ci.yaml/badge.svg)\n\nPython library to detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data.\n\n# Documentation\n\n## Installation\n\n```sh\npip install ua-parser-py\n```\n\n## Constructor\n\n* `UAParser([uastring])`\n    * returns new instance\n\n* `UAParser.parse([uastring])`\n    * returns result object `{ 'ua': '', 'browser': {}, 'cpu': {}, 'device': {}, 'engine': {}, 'os': {} }`\n\n## Properties\n\n* `browser`\n    * returns `{ 'name': '', 'version': '' }`\n\n```sh\n# Possible 'browser.name':\n2345Explorer, 360 Browser, Alipay, Amaya, Android Browser, Arora, Avant, Avast, \nAVG, Baidu, Basilisk, Blazer, Bolt, Brave, Bowser, Camino, Chimera,\nChrome Headless, Chrome WebView, Chrome, Chromium, Cobalt, Comodo Dragon, Dillo,\nDolphin, Doris, DuckDuckGo, Edge, Electron, Epiphany, Facebook, Falkon, Fennec, \nFirebird, Firefox [Focus/Reality], Flock, Flow, GSA, GoBrowser, Heytap, \nHuawei Browser, iCab, ICE Browser, IE, IEMobile, IceApe, IceCat, IceDragon, \nIceweasel, Instagram, Iridium, Iron, Jasmine, Kakao[Story/Talk], K-Meleon, \nKindle, Klar, Klarna, Konqueror, LBBROWSER, Line, LinkedIn, Links, Lunascape, \nLynx, MIUI Browser, Maemo, Maxthon, Midori, Minimo, Mobile Safari, Mosaic, \nMozilla, NetFront, NetSurf, Netfront, Netscape, NokiaBrowser, Obigo, \nOculus Browser, OmniWeb, Opera Coast, Opera [Mini/Mobi/Tablet], PaleMoon, \nPhantomJS, Phoenix, Polaris, Puffin, QQ, QQBrowser, QQBrowserLite, Quark, \nQupZilla, RockMelt, Safari, Sailfish Browser, Samsung Internet, SeaMonkey, Silk, \nSkyfire, Sleipnir, Slim, SlimBrowser, Smart Lenovo Browser, Snapchat, \nSogou [Explorer/Mobile], Swiftfox, Tesla, TikTok, Tizen Browser, UCBrowser, \nUP.Browser, Viera, Vivaldi, Vivo Browser, Waterfox, WeChat, Weibo, Yandex, w3m, \nWhale Browser, ...\n\n# 'browser.version' determined dynamically\n```\n\n* `device`\n    * returns `{ 'model': '', 'type': '', 'vendor': '' }`\n\n```sh\n# Possible 'device.type':\nconsole, mobile, tablet, smarttv, wearable, embedded\n\n##########\n# NOTE: 'desktop' is not a possible device type. \n# UAParser only reports info directly available from the UA string, which is not the case for 'desktop' device type.\n# If you wish to detect desktop devices, you must handle the needed logic yourself.\n# You can read more about it in this issue: https://github.com/faisalman/ua-parser-js/issues/182\n##########\n\n# Possible 'device.vendor':\nAcer, Alcatel, Amazon, Apple, Archos, ASUS, AT&T, BenQ, BlackBerry, Dell,\nEssential, Facebook, Fairphone, GeeksPhone, Google, HP, HTC, Huawei, Infinix, \nJolla, Kobo, Lenovo, LG, Meizu, Microsoft, Motorola, Nexian, Nintendo, Nokia, \nNvidia, OnePlus, OPPO, Ouya, Palm, Panasonic, Pebble, Polytron, Realme, RIM, \nRoku, Samsung, Sharp, Siemens, Sony[Ericsson], Sprint, Tecno, Tesla, Ulefone, \nVivo, Vodafone, Xbox, Xiaomi, Zebra, ZTE, ...\n\n# 'device.model' determined dynamically\n```\n\n* `engine`\n    * returns `{ 'name': '', 'version': '' }`\n\n```sh\n# Possible 'engine.name'\nAmaya, Blink, EdgeHTML, Flow, Gecko, Goanna, iCab, KHTML, LibWeb, Links, Lynx, \nNetFront, NetSurf, Presto, Tasman, Trident, w3m, WebKit\n\n# 'engine.version' determined dynamically\n```\n\n* `os`\n    * returns `{ 'name': '', 'version': '' }`\n\n```sh\n# Possible 'os.name'\nAIX, Amiga OS, Android[-x86], Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS,\nContiki, Fedora, Firefox OS, FreeBSD, Debian, Deepin, DragonFly, elementary OS, \nFuchsia, Gentoo, GhostBSD, GNU, Haiku, HarmonyOS, HP-UX, Hurd, iOS, Joli, KaiOS, \nLinpus, Linspire,Linux, Mac OS, Maemo, Mageia, Mandriva, Manjaro, MeeGo, Minix, \nMint, Morph OS, NetBSD, NetRange, NetTV, Nintendo, OpenBSD, OpenVMS, OS/2, Palm, \nPC-BSD, PCLinuxOS, Plan9, PlayStation, QNX, Raspbian, RedHat, RIM Tablet OS, \nRISC OS, Sabayon, Sailfish, SerenityOS, Series40, Slackware, Solaris, SUSE, \nSymbian, Tizen, Ubuntu, Unix, VectorLinux, Viera, watchOS, WebOS, \nWindows [Phone/Mobile], Zenwalk, ...\n\n# 'os.version' determined dynamically\n```\n\n* `cpu`\n    * returns `{ 'architecture': '' }`\n\n```sh\n# Possible 'cpu.architecture'\n68k, amd64, arm[64/hf], avr, ia[32/64], irix[64], mips[64], pa-risc, ppc, \nsparc[64]\n```\n\n* `ua`\n    * returns UA string of current instance\n\n# Usage\n\n```python3\nimport json\nfrom uaparser import UAParser\n\nuastring1 = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2'\nresult = UAParser(uastring1)\n\nprint(result.browser)  # {'name': 'Chromium', 'version': '15.0.874.106', 'major': '15'}\nprint(result.device)  # {'vendor': None, 'model': None, 'type': None}\nprint(result.os)  # {'name': 'Ubuntu', 'version': '11.10'}\nprint(result.os['version'])  # '11.10'\nprint(result.engine['name'])  # 'WebKit'\nprint(result.cpu['architecture'])  # 'amd64'\n\nuastring2 = 'Mozilla/5.0 (compatible; Konqueror/4.1; OpenBSD) KHTML/4.1.4 (like Gecko)'\nresult = UAParser.parse(uastring2)\n\nprint(result['browser']['name'])  # 'Konqueror\nprint(result['os'])  # {'name': 'OpenBSD', 'version': None}\nprint(result['engine'])  # {'name': 'KHTML', 'version': '4.1.4'}\n\nuastring3 = 'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.11 (KHTML, like Gecko) Version/7.1.0.7 Safari/534.11'\nresult = UAParser.parse(uastring3)\n\nprint(json.dumps(result, indent=4))\n# {\n#   \"ua\": \"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.11 (KHTML, like Gecko) Version/7.1.0.7 Safari/534.11\",\n#   \"browser\": {\n#     \"name\": \"Safari\",\n#     \"version\": \"7.1.0.7\",\n#     \"major\": \"7\" // @deprecated\n#   },\n#   \"cpu\": {\n#     \"architecture\": null\n#   },\n#   \"device\": {\n#     \"vendor\": \"RIM\",\n#     \"model\": \"PlayBook\",\n#     \"type\": \"tablet\"\n#   },\n#   \"engine\": {\n#     \"name\": \"WebKit\",\n#     \"version\": \"534.11\"\n#   },\n#   \"os\": {\n#     \"name\": \"RIM Tablet OS\",\n#     \"version\": \"1.0.0\"\n#   }\n# }\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python library to detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data",
    "version": "1.0.37",
    "project_urls": {
        "Homepage": "https://github.com/vitalibo/ua-parser-py"
    },
    "split_keywords": [
        "user-agent",
        "parser",
        "browser",
        "engine",
        "os",
        "device",
        "cpu"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6d9f7b8154a0bd5eacf44dd84e0cd8811bd4f26c7e49ad7695d78829a6f5288b",
                "md5": "c616b565d415916a61bb5dd2d352b696",
                "sha256": "f4f0305b973785eadf7dbe5a6b5ac6c5757d53ad78e3a3b32ebbfdda47390042"
            },
            "downloads": -1,
            "filename": "ua_parser_py-1.0.37-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c616b565d415916a61bb5dd2d352b696",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 18239,
            "upload_time": "2024-03-31T03:47:05",
            "upload_time_iso_8601": "2024-03-31T03:47:05.186393Z",
            "url": "https://files.pythonhosted.org/packages/6d/9f/7b8154a0bd5eacf44dd84e0cd8811bd4f26c7e49ad7695d78829a6f5288b/ua_parser_py-1.0.37-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3b67dfe240aa0ab1e444986e1cef8d304dea2cf1a8389cd04710e3d0af1deab8",
                "md5": "c1c9675c9aa7121ebbe9ae0712b53c16",
                "sha256": "078eb0149d143743bd4a7a8d0e0187db6f376be0acded8d2c7bf4148185ce1ca"
            },
            "downloads": -1,
            "filename": "ua-parser-py-1.0.37.tar.gz",
            "has_sig": false,
            "md5_digest": "c1c9675c9aa7121ebbe9ae0712b53c16",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 17373,
            "upload_time": "2024-03-31T03:47:06",
            "upload_time_iso_8601": "2024-03-31T03:47:06.843867Z",
            "url": "https://files.pythonhosted.org/packages/3b/67/dfe240aa0ab1e444986e1cef8d304dea2cf1a8389cd04710e3d0af1deab8/ua-parser-py-1.0.37.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-31 03:47:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vitalibo",
    "github_project": "ua-parser-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "6.2.5"
                ]
            ]
        },
        {
            "name": "setuptools",
            "specs": [
                [
                    "==",
                    "59.6.0"
                ]
            ]
        },
        {
            "name": "wheel",
            "specs": [
                [
                    "==",
                    "0.37.1"
                ]
            ]
        },
        {
            "name": "twine",
            "specs": [
                [
                    "==",
                    "3.8.0"
                ]
            ]
        }
    ],
    "lcname": "ua-parser-py"
}
        
Elapsed time: 0.28735s