Skip to main content

Python port of Browserscope's user agent parser

Project description

#uap-python
A python implementation of the UA Parser (https://github.com/ua-parser, formerly https://github.com/tobie/ua-parser)

##Build Status

[![Build Status](https://travis-ci.org/ua-parser/uap-python.svg)](https://travis-ci.org/ua-parser/uap-python)

##Installing

In the top-level directory run:
```
$ make
```

##Getting Started

### retrieve data on a user-agent string
```
>>> import user_agent_parser
>>> import pprint
>>> pp = pprint.PrettyPrinter(indent=4)
>>> 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'
>>> parsed_string = user_agent_parser.Parse(ua_string)
>>> pp.pprint(parsed_string)
{ 'device': { 'brand': None, 'family': 'Other', 'model': None},
'os': { 'family': 'Mac OS X',
'major': '10',
'minor': '9',
'patch': '4',
'patch_minor': None},
'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',
'user_agent': { 'family': 'Chrome',
'major': '41',
'minor': '0',
'patch': '2272'}}
```


### extract browser data from user-agent string

```
>>> import user_agent_parser
>>> import pprint
>>> pp = pprint.PrettyPrinter(indent=4)
>>> 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'
>>> parsed_string = user_agent_parser.ParseUserAgent(ua_string)
>>> pp.pprint(parsed_string)
{ 'family': 'Chrome',
'major': '41',
'minor': '0',
'patch': '2272'}
```

### extract OS information from user-agent string

```
>>> import user_agent_parser
>>> import pprint
>>> pp = pprint.PrettyPrinter(indent=4)
>>> 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'
>>> parsed_string = user_agent_parser.ParseOS(ua_string)
>>> pp.pprint(parsed_string)
{ 'family': 'Mac OS X',
'major': '10',
'minor': '9',
'patch': '4',
'patch_minor': None}
```

### extract Device information from user-agent string


```
>>> import user_agent_parser
>>> import pprint
>>> pp = pprint.PrettyPrinter(indent=4)
>>> 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'
>>> parsed_string = user_agent_parser.ParseDevice(ua_string)
>>> pp.pprint(parsed_string)
{ 'brand': None,
'family': 'Other',
'model': None}
```


## Copyright

Copyright 2008 Google Inc. See ua_parser/LICENSE for more information

Project details


Download files

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

Source Distribution

ua-parser-0.5.1.tar.gz (64.9 kB view details)

Uploaded Source

Built Distribution

ua_parser-0.5.1-py2.py3-none-any.whl (66.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file ua-parser-0.5.1.tar.gz.

File metadata

  • Download URL: ua-parser-0.5.1.tar.gz
  • Upload date:
  • Size: 64.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ua-parser-0.5.1.tar.gz
Algorithm Hash digest
SHA256 49414e54d98c0a1c4d1cbbbce228373d4d945f04f5621f0ea1fdc202930b1e20
MD5 9a8fc4371970d93c77d1c6249e7fab37
BLAKE2b-256 b5e895769de9f586b5d04e2f72f08f925dcdbd0068bb92313a8c18a8e80d9bed

See more details on using hashes here.

File details

Details for the file ua_parser-0.5.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for ua_parser-0.5.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 69a4cdaef3268d88f2dc6f8b8f5c3a13955fe3daa5f59746a817dcf891be5899
MD5 22c8a9d901b68444f6f319092d08a1f8
BLAKE2b-256 e411511fdd980396346830682f208f6905b28c00a17164afee023dad78cc59b9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page