Skip to main content

UNKNOWN

Project description

==================================
useragent
==================================

useragent is a Python library that parses HTTP User-agent strings
and tries to give you as much data as possible in a normalized form.

It uses the data provided by the ua-parser project (originally collected by
Steve Souders). It aims to be more pythonic than the python wrapper found
in the original ua-parser project.

To-wit::

#!/usr/bin/env python

import useragent
ua = useragent.detect("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; nl; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1")
print(ua)

Which would print ``ua``, a dict-like object with the following structure::
{
'device': {
'family': None,
'major_version': None,
'minor_version': None,
'patch_version': None
},
'os': {
'family': 'Mac OS X',
'major_version': '10',
'minor_version': '5',
'patch_version': None
},
'browser': {
'family': 'Firefox',
'major_version': '3',
'minor_version': '0',
'patch_version': '1'
}
}

The ``ua`` object actually has each of those keys exposed as attributes on itself, so you may find it more comfortable to navigate like so::
print(ua.browser.family)
print(ua.os.family)
print(ua.device.family)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for useragent, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size useragent-0.1.1.tar.gz (134.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page