fastuaparser


Namefastuaparser JSON
Version 0.1.4 PyPI version JSON
download
home_pageNone
SummaryA super-fast user agent string parser
upload_time2025-01-30 14:07:54
maintainerNone
docs_urlNone
authorAlmar Klein
requires_python>=3.6
licenseNone
keywords user-agent web analytics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # fastuaparser
A super-fast user-agent string parser


## Usage

```py
from fastuaparser import parse_ua

# Parse the header info
client_os = parse_ua(headers.get("user-agent", ""))

# Split in browser-type and OS
client, os = client_os.partition(' - ')
```

The `parse_ua()` function never raises an exception, just tries
to make as much from whatever you feed it.


## A bit less precise, a whole lot faster

This code is less precise than https://github.com/ua-parser/uap-python,
in that it marks rare browsers as either "Browser" or as the browser
that it's based upon (e.g. IceWeasel becomes Firefox). It also marks
all bots as simply "Bot" and does not care about TV's that have a
browser. Other than that, this function is quite accurate and passes
ua-parser's test suite.

If you can live with the above restrictions (you probably can if
you're using this to e.g. monitor your website's traffic) then use
this function: it's over 100 times faster that ua_parser!

On the ua-parser's set of ua strings, it renders close to 1M strings per second (in my Mac M1).


## Docs

```py

def parse_ua(s: str, always_include_os: bool = False) -> str:
    """Parse the given user-agent string and return a short description.

    The returned string has the form "client - os".

    The client is "Browser" if unknown. The os is "Other" if unknown
    and may contain a string "Mobile", "Tablet" or "Desktop. When the
    ua does not represent a browser (but e.g. a bot or wget) the os is
    omitted (unless always_include_os is True).
    """
    ...
```


## Origins

This code used to be part of [my time tracking app](https://timetagger.app),
which went open source, and I rolled some components (like this one) into
their own little project.


## License

MIT

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fastuaparser",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "user-agent, web, analytics",
    "author": "Almar Klein",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/38/c8/5f8d0f39e5827555598859248fa84f8633493266507ddb902590e6488edf/fastuaparser-0.1.4.tar.gz",
    "platform": null,
    "description": "# fastuaparser\nA super-fast user-agent string parser\n\n\n## Usage\n\n```py\nfrom fastuaparser import parse_ua\n\n# Parse the header info\nclient_os = parse_ua(headers.get(\"user-agent\", \"\"))\n\n# Split in browser-type and OS\nclient, os = client_os.partition(' - ')\n```\n\nThe `parse_ua()` function never raises an exception, just tries\nto make as much from whatever you feed it.\n\n\n## A bit less precise, a whole lot faster\n\nThis code is less precise than https://github.com/ua-parser/uap-python,\nin that it marks rare browsers as either \"Browser\" or as the browser\nthat it's based upon (e.g. IceWeasel becomes Firefox). It also marks\nall bots as simply \"Bot\" and does not care about TV's that have a\nbrowser. Other than that, this function is quite accurate and passes\nua-parser's test suite.\n\nIf you can live with the above restrictions (you probably can if\nyou're using this to e.g. monitor your website's traffic) then use\nthis function: it's over 100 times faster that ua_parser!\n\nOn the ua-parser's set of ua strings, it renders close to 1M strings per second (in my Mac M1).\n\n\n## Docs\n\n```py\n\ndef parse_ua(s: str, always_include_os: bool = False) -> str:\n    \"\"\"Parse the given user-agent string and return a short description.\n\n    The returned string has the form \"client - os\".\n\n    The client is \"Browser\" if unknown. The os is \"Other\" if unknown\n    and may contain a string \"Mobile\", \"Tablet\" or \"Desktop. When the\n    ua does not represent a browser (but e.g. a bot or wget) the os is\n    omitted (unless always_include_os is True).\n    \"\"\"\n    ...\n```\n\n\n## Origins\n\nThis code used to be part of [my time tracking app](https://timetagger.app),\nwhich went open source, and I rolled some components (like this one) into\ntheir own little project.\n\n\n## License\n\nMIT\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A super-fast user agent string parser ",
    "version": "0.1.4",
    "project_urls": {
        "Homepage": "https://github.com/almarklein/fastuaparser",
        "Repository": "https://github.com/almarklein/fastuaparser"
    },
    "split_keywords": [
        "user-agent",
        " web",
        " analytics"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "15e039fa18142fd1e9de6e207409dd8e5f90c1cc1346a838ce81a250c3a195fa",
                "md5": "eaed1a36204c7903ea741af9880249bc",
                "sha256": "9f84be99b435c73849d408b6cd161bdc752881054a7731a810d0deb8fd89842e"
            },
            "downloads": -1,
            "filename": "fastuaparser-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "eaed1a36204c7903ea741af9880249bc",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 4561,
            "upload_time": "2025-01-30T14:07:53",
            "upload_time_iso_8601": "2025-01-30T14:07:53.431648Z",
            "url": "https://files.pythonhosted.org/packages/15/e0/39fa18142fd1e9de6e207409dd8e5f90c1cc1346a838ce81a250c3a195fa/fastuaparser-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "38c85f8d0f39e5827555598859248fa84f8633493266507ddb902590e6488edf",
                "md5": "e7cbda374ca8e2d33d8f704e650f86ab",
                "sha256": "c0b9113d17e40705dbf4582ca1303c703e2ea03ffdb2f0507afe267a317a3e79"
            },
            "downloads": -1,
            "filename": "fastuaparser-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "e7cbda374ca8e2d33d8f704e650f86ab",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 8591,
            "upload_time": "2025-01-30T14:07:54",
            "upload_time_iso_8601": "2025-01-30T14:07:54.759669Z",
            "url": "https://files.pythonhosted.org/packages/38/c8/5f8d0f39e5827555598859248fa84f8633493266507ddb902590e6488edf/fastuaparser-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-30 14:07:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "almarklein",
    "github_project": "fastuaparser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "fastuaparser"
}
        
Elapsed time: 3.10173s