跳转到主要内容

从HTTP用户代理字符串中提取操作系统、浏览器等信息

项目描述

http://pepy.tech/badge/httpagentparser https://img.shields.io/pypi/v/httpagentparser.svg https://img.shields.io/travis/shon/httpagentparser.svg https://img.shields.io/travis/shon/httpagentparser.svg

功能

  • 快速

  • 检测操作系统和浏览器。不旨在成为功能齐全的代理解析器

  • 不会变成django-httpagentparser ;)

用法

>>> import httpagentparser
>>> s = "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/532.9 (KHTML, like Gecko) \
        Chrome/5.0.307.11 Safari/532.9"
>>> print(httpagentparser.simple_detect(s))
('Linux', 'Chrome 5.0.307.11')
>>> print(httpagentparser.detect(s))
{'os': {'name': 'Linux'},
 'browser': {'version': '5.0.307.11', 'name': 'Chrome'}}

>>> s = "Mozilla/5.0 (Linux; U; Android 2.3.5; en-in; HTC_DesireS_S510e Build/GRJ90) \
        AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
>>> print(httpagentparser.simple_detect(s))
('Android Linux 2.3.5', 'Safari 4.0')
>>> print(httpagentparser.detect(s))
{'dist': {'version': '2.3.5', 'name': 'Android'},
'os': {'name': 'Linux'},
'browser': {'version': '4.0', 'name': 'Safari'}}

历史

http://stackoverflow.com/questions/927552/parsing-http-user-agent-string/1151956#1151956

项目详情


下载文件

下载适合您平台的项目文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分发

httpagentparser-1.9.5.tar.gz (7.7 kB 查看哈希值)

上传时间 源代码

由以下组织支持