Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Python implementation of ua-parser

NotificationsYou must be signed in to change notification settings

pythonthings/uap-python

 
 

Repository files navigation

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

Build Status

Installing

Install via pip

Just run:

$ pip install ua-parser

Manual install

In the top-level directory run:

$ python setup.py install

Change Log

Because this repo is mostly a python wrapper for the User Agent String Parser repo (https://github.com/ua-parser/uap-core), the changes made to this repo are best described by the update diffs in that project. Please see the diffs for this submodule (https://github.com/ua-parser/uap-core/releases) for a list of what has changed between versions of this package.

Getting Started

Retrieve data on a user-agent string

>>>fromua_parserimportuser_agent_parser>>>importpprint>>>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':'Apple','family':'Mac','model':'Mac'},'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

>>>fromua_parserimportuser_agent_parser>>>importpprint>>>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

>>>fromua_parserimportuser_agent_parser>>>importpprint>>>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

>>>fromua_parserimportuser_agent_parser>>>importpprint>>>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':'Apple','family':'Mac','model':'Mac'}

Copyright

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

About

Python implementation of ua-parser

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python98.5%
  • Makefile1.5%

[8]ページ先頭

©2009-2025 Movatter.jp