Name | ua-parser JSON |
Version |
1.0.1
JSON |
| download |
home_page | None |
Summary | Python port of Browserscope's user agent parser |
upload_time | 2025-02-01 14:13:32 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | Apache 2.0 |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
uap-python
==========
Official python implementation of the `User Agent String
Parser <https://github.com/ua-parser>`_ project.
Build Status
------------
.. image:: https://github.com/ua-parser/uap-python/actions/workflows/ci.yml/badge.svg
:target: https://github.com/ua-parser/uap-python/actions/workflows/ci.yml?query=branch%3Amaster
:alt: CI on the master branch
.. image:: https://readthedocs.org/projects/uap-python/badge/?version=latest
:target: https://uap-python.readthedocs.io/
:alt: Documentation Status
Installing
----------
Add ``ua-parser[regex]`` to your project's dependencies, or run
.. code-block:: sh
$ pip install 'ua-parser[regex]'
to install in the current environment.
ua-parser supports CPython 3.9 and newer, recent pypy (supporting
3.10), and GraalPy 24.
.. note::
The ``[regex]`` feature is *strongly* recommended:
- ``[re2]`` is slightly slower and only works with cpython, though
it is still a great option then (and is more memory-efficient).
- Pure python (no feature) is *significantly* slower, especially on
non-cpython runtimes, but it is the most memory efficient even
with caches.
See `builtin resolvers`_ for more explanation of the tradeoffs
between the different options.
.. _builtin resolvers: https://uap-python.readthedocs.io/stable/guides.html#builtin-resolvers
Quick Start
-----------
Retrieve all data on a user-agent string
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
>>> from ua_parser import parse
>>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'
>>> parse(ua_string) # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
Result(user_agent=UserAgent(family='Chrome',
major='41',
minor='0',
patch='2272',
patch_minor='104'),
os=OS(family='Mac OS X',
major='10',
minor='9',
patch='4',
patch_minor=None),
device=Device(family='Mac',
brand='Apple',
model='Mac'),
string='Mozilla/5.0 (Macintosh; Intel Mac OS...
Any datum not found in the user agent string is set to ``None``::
>>> parse("")
Result(user_agent=None, os=None, device=None, string='')
Extract only browser data from user-agent string
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
>>> from ua_parser import parse_user_agent
>>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'
>>> parse_user_agent(ua_string)
UserAgent(family='Chrome', major='41', minor='0', patch='2272', patch_minor='104')
For specific domains, a match failure just returns ``None``::
>>> parse_user_agent("")
Extract OS information from user-agent string
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
>>> from ua_parser import parse_os
>>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'
>>> parse_os(ua_string)
OS(family='Mac OS X', major='10', minor='9', patch='4', patch_minor=None)
Extract device information from user-agent string
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
>>> from ua_parser import parse_device
>>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'
>>> parse_device(ua_string)
Device(family='Mac', brand='Apple', model='Mac')
Upgrading
---------
Upgrading from 0.x? See `the upgrade guide`_.
.. _the upgrade guide: https://uap-python.readthedocs.io/stable/advanced/migration.html
Raw data
{
"_id": null,
"home_page": null,
"name": "ua-parser",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "masklinn <uap@masklinn.net>",
"keywords": null,
"author": null,
"author_email": "Stephen Lamm <slamm@google.com>, PBS <no-reply@pbs.org>, Selwin Ong <selwin.ong@gmail.com>, Matt Robenolt <matt@ydekproductions.com>, Lindsey Simon <lsimon@commoner.com>",
"download_url": "https://files.pythonhosted.org/packages/70/0e/ed98be735bc89d5040e0c60f5620d0b8c04e9e7da99ed1459e8050e90a77/ua_parser-1.0.1.tar.gz",
"platform": null,
"description": "uap-python\n==========\n\nOfficial python implementation of the `User Agent String\nParser <https://github.com/ua-parser>`_ project.\n\nBuild Status\n------------\n\n.. image:: https://github.com/ua-parser/uap-python/actions/workflows/ci.yml/badge.svg\n :target: https://github.com/ua-parser/uap-python/actions/workflows/ci.yml?query=branch%3Amaster\n :alt: CI on the master branch\n\n.. image:: https://readthedocs.org/projects/uap-python/badge/?version=latest\n :target: https://uap-python.readthedocs.io/\n :alt: Documentation Status\n\nInstalling\n----------\n\nAdd ``ua-parser[regex]`` to your project's dependencies, or run\n\n.. code-block:: sh\n\n $ pip install 'ua-parser[regex]'\n\nto install in the current environment.\n\nua-parser supports CPython 3.9 and newer, recent pypy (supporting\n3.10), and GraalPy 24.\n\n.. note::\n\n The ``[regex]`` feature is *strongly* recommended:\n\n - ``[re2]`` is slightly slower and only works with cpython, though\n it is still a great option then (and is more memory-efficient).\n - Pure python (no feature) is *significantly* slower, especially on\n non-cpython runtimes, but it is the most memory efficient even\n with caches.\n\n See `builtin resolvers`_ for more explanation of the tradeoffs\n between the different options.\n\n.. _builtin resolvers: https://uap-python.readthedocs.io/stable/guides.html#builtin-resolvers\n\nQuick Start\n-----------\n\nRetrieve all data on a user-agent string\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n >>> from ua_parser import parse\n >>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'\n >>> parse(ua_string) # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS\n Result(user_agent=UserAgent(family='Chrome',\n major='41',\n minor='0',\n patch='2272',\n patch_minor='104'),\n os=OS(family='Mac OS X',\n major='10',\n minor='9',\n patch='4',\n patch_minor=None),\n device=Device(family='Mac',\n brand='Apple',\n model='Mac'),\n string='Mozilla/5.0 (Macintosh; Intel Mac OS...\n\nAny datum not found in the user agent string is set to ``None``::\n\n >>> parse(\"\")\n Result(user_agent=None, os=None, device=None, string='')\n\nExtract only browser data from user-agent string\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n >>> from ua_parser import parse_user_agent\n >>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'\n >>> parse_user_agent(ua_string)\n UserAgent(family='Chrome', major='41', minor='0', patch='2272', patch_minor='104')\n\nFor specific domains, a match failure just returns ``None``::\n\n >>> parse_user_agent(\"\")\n\nExtract OS information from user-agent string\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n >>> from ua_parser import parse_os\n >>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'\n >>> parse_os(ua_string)\n OS(family='Mac OS X', major='10', minor='9', patch='4', patch_minor=None)\n\nExtract device information from user-agent string\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n >>> from ua_parser import parse_device\n >>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'\n >>> parse_device(ua_string)\n Device(family='Mac', brand='Apple', model='Mac')\n\nUpgrading\n---------\n\nUpgrading from 0.x? See `the upgrade guide`_.\n\n.. _the upgrade guide: https://uap-python.readthedocs.io/stable/advanced/migration.html\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "Python port of Browserscope's user agent parser",
"version": "1.0.1",
"project_urls": {
"documentation": "https://uap-python.readthedocs.io",
"issues": "https://github.com/ua-parser/uap-python/issues",
"repository": "https://github.com/ua-parser/uap-python"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "9437be6dfbfa45719aa82c008fb4772cfe5c46db765a2ca4b6f524a1fdfee4d7",
"md5": "58a375989ccb7e27d0c0ed5ac0c5728f",
"sha256": "b059f2cb0935addea7e551251cbbf42e9a8872f86134163bc1a4f79e0945ffea"
},
"downloads": -1,
"filename": "ua_parser-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "58a375989ccb7e27d0c0ed5ac0c5728f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 31410,
"upload_time": "2025-02-01T14:13:28",
"upload_time_iso_8601": "2025-02-01T14:13:28.458059Z",
"url": "https://files.pythonhosted.org/packages/94/37/be6dfbfa45719aa82c008fb4772cfe5c46db765a2ca4b6f524a1fdfee4d7/ua_parser-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "700eed98be735bc89d5040e0c60f5620d0b8c04e9e7da99ed1459e8050e90a77",
"md5": "256b5c489d8ee11a498295c4a487227a",
"sha256": "f9d92bf19d4329019cef91707aecc23c6d65143ad7e29a233f0580fb0d15547d"
},
"downloads": -1,
"filename": "ua_parser-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "256b5c489d8ee11a498295c4a487227a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 728106,
"upload_time": "2025-02-01T14:13:32",
"upload_time_iso_8601": "2025-02-01T14:13:32.508212Z",
"url": "https://files.pythonhosted.org/packages/70/0e/ed98be735bc89d5040e0c60f5620d0b8c04e9e7da99ed1459e8050e90a77/ua_parser-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-01 14:13:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ua-parser",
"github_project": "uap-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "ua-parser"
}