Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
This library parses browser user-agent strings with data from 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()
print ua.parse() # returns all parsed fields for the UA string
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.
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.
FAQs
Library for parsing browser user agents
We found that uaparser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.