Browser user-agent detection
This library parses browser user-agent strings with data from [user-agent-string.info](http://user-agent-string.info/).
This library is loosely based on the work by Hicro Kee (hicrokee AT gmail DOT com) and Michal Molhanec (http://molhanec.net).
Usage:
from uaparser import UA, UAParser parser = UAParser() parser.update_data() ua = UA(parser, user_agent_string) print ua.is_robot() # returns empty dictionary if robot is not detected print ua.get_browser_details() # returns empty dictionary, or browser details print ua.get_device_type() # returns dict containing device type fields print ua.get_os_details() # Or alternatively, print ua.parse() # returns all parsed fields for the UA string
Django integration
As running a large number of regexes takes a long time, Django integration uses caching.
Usage:
from uaparser.django.caching_ua_parser import parse_user_agent
parsed = parse_user_agent(request.META.get("HTTP_USER_AGENT"))
parse_user_agent fetches all user-agent fields (i.e it calls ua.parse()).
Settings:
UA_CACHE_DIRECTORY: directory for data file (“cache.pickle”). Mandatory.
UA_CACHE_NAME: defaults to “default”. Defines custom Django cache name.
UA_CACHE_PREFIX: defaults to “parse_ua”. Key prefix for cache.
UA_CACHE_TIMEOUT: defaults to 48 hours. Cache key timeout in seconds.
Middleware: add uaparser.django.middleware.UAParserMiddleware to MIDDLEWARE_CLASSES.
Context processor: to add parsed_ua variable to context, add uaparser.django.context_processor.add_parsed_ua to CONTEXT_PROCESSORS. This does nothing if UAParserMiddleware is not enabled.
License
Licensed under the MIT license.
Copyright (c) 2014 Olli Jarva <olli@jarva.fi>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Metadata
Release files for uaparser 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| uaparser-0.1.0.tar.gz | 6.2 kB | Without provenance | Details for uaparser-0.1.0.tar.gz |
Release files / uaparser-0.1.0.tar.gz
| Download URL | uaparser-0.1.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
509e17a5b19b077e307cfbee767e2eb5a0e2dea5f64d06ee93dcb57a4ce1aac5
|
|
BLAKE2b-256 checksum How to use checksums |
2d34005c13082426b78e8bad3ce2c5ae7d969887e11779ebd35146c40a4551b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for uaparser 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.