跳转到主要内容

快速可靠的Python用户代理解析器和IP分类器

项目描述

Python(数据版4)的Udger客户端

本地解析器是一个非常快速且精确的用户代理字符串检测解决方案。使开发者能够本地安装和集成一个高度可扩展的产品。我们提供设备(个人电脑、平板电脑、智能电视、游戏机等)的检测,操作系统和客户端软件类型(浏览器、电子邮件客户端等)。它还提供有关IP地址的信息(公共代理、VPN服务、Tor出口节点、假爬虫、网络爬虫等)

  • 测试了超过50,000个独特的用户代理。
  • https://udger.com/提供最新的数据
  • 支持Python 3

享受吧!

使用pip安装

$ pip install udger-v4

从git仓库安装

$ git clone https://github.com/udger/udger-python-v4
$ cd udger-python-v4/
# python setup.py install

自动更新下载

对于数据自动更新,请使用Udger数据更新器(https://udger.com/support/documentation/?doc=62

帮助我们

请随意在GitHub上向我们发送拉取请求,以帮助我们改进Python版的Udger。或者,只需告诉我们您遇到的问题。

谢谢!

用法

    $ python
    >>> from pprint import pprint
    >>> from udger import Udger
    >>> from udger import UaRequest
    >>> udger = Udger()
    >>>
    >>> result = udger.parse_ua(
    ...     'Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53'
    ... )
    >>> pprint(result)
    {'crawler_category': None,
     'crawler_category_code': None,
     'crawler_last_seen': None,
     'crawler_respect_robotstxt': None,
     'device_brand': 'Apple',
     'device_brand_code': 'apple',
     'device_brand_homepage': 'https://www.apple.com/',
     'device_brand_icon': 'apple.png',
     'device_brand_icon_big': 'apple_big.png',
     'device_brand_info_url': 'https://udger.com/resources/ua-list/devices-brand-detail?brand=apple',
     'device_class': 'Tablet',
     'device_class_code': 'tablet',
     'device_class_icon': 'tablet.png',
     'device_class_icon_big': 'tablet_big.png',
     'device_class_info_url': 'https://udger.com/resources/ua-list/device-detail?device=Tablet',
     'device_marketname': 'iPad',
     'os': 'iOS 7',
     'os_code': 'ios_7',
     'os_family': 'iOS',
     'os_family_code': 'ios',
     'os_family_vendor': 'Apple Inc.',
     'os_family_vendor_code': 'apple_inc',
     'os_family_vendor_homepage': 'https://www.apple.com/',
     'os_homepage': 'https://en.wikipedia.org/wiki/IOS_7',
     'os_icon': 'iphone.png',
     'os_icon_big': 'iphone_big.png',
     'os_info_url': 'https://udger.com/resources/ua-list/os-detail?os=iOS%207',
     'sec_ch_ua': None,
     'sec_ch_ua_full_version': None,
     'sec_ch_ua_full_version_list': None,
     'sec_ch_ua_mobile': '',
     'sec_ch_ua_model': None,
     'sec_ch_ua_platform': None,
     'sec_ch_ua_platform_version': None,
     'ua': 'Safari mobile 7.0',
     'ua_class': 'Mobile browser',
     'ua_class_code': 'mobile_browser',
     'ua_engine': 'WebKit',
     'ua_family': 'Safari mobile',
     'ua_family_code': 'safari_mobile',
     'ua_family_homepage': 'https://en.wikipedia.org/wiki/Safari_(web_browser)',
     'ua_family_icon': 'safari.png',
     'ua_family_icon_big': 'safari_big.png',
     'ua_family_info_url': 'https://udger.com/resources/ua-list/browser-detail?browser=Safari%20mobile',
     'ua_family_vendor': 'Apple Inc.',
     'ua_family_vendor_code': 'apple_inc',
     'ua_family_vendor_homepage': 'https://www.apple.com/',
     'ua_string': 'Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) '
                  'AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 '
                  'Mobile/11A465 Safari/9537.53',
     'ua_uptodate_current_version': '15',
     'ua_version': '7.0',
     'ua_version_major': '7'}
    >>>
    >>> ua_request=UaRequest(ua_string='',sec_ch_ua='" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"', 
    ...                      sec_ch_ua_full_version_list='', sec_ch_ua_mobile='?0', sec_ch_ua_full_version='"97.0.4692.71"', 
    ...                      sec_ch_ua_platform='', sec_ch_ua_platform_version='', sec_ch_ua_model=''
    >>> )
    >>>     
    >>> pprint(result)
    {'crawler_category': None,
     'crawler_category_code': None,
     'crawler_last_seen': None,
     'crawler_respect_robotstxt': None,
     'device_brand': None,
     'device_brand_code': None,
     'device_brand_homepage': None,
     'device_brand_icon': None,
     'device_brand_icon_big': None,
     'device_brand_info_url': None,
     'device_class': 'Desktop',
     'device_class_code': 'desktop',
     'device_class_icon': 'desktop.png',
     'device_class_icon_big': 'desktop_big.png',
     'device_class_info_url': 'https://udger.com/resources/ua-list/device-detail?device=Desktop',
     'device_marketname': None,
     'os': None,
     'os_code': None,
     'os_family': None,
     'os_family_code': None,
     'os_family_vendor': None,
     'os_family_vendor_code': None,
     'os_family_vendor_homepage': None,
     'os_homepage': None,
     'os_icon': None,
     'os_icon_big': None,
     'os_info_url': None,
     'sec_ch_ua': '" Not;A Brand";v="99", "Google Chrome";v="97", '
                  '"Chromium";v="97"',
     'sec_ch_ua_full_version': '97.0.4692.71',
     'sec_ch_ua_full_version_list': None,
     'sec_ch_ua_mobile': 0,
     'sec_ch_ua_model': None,
     'sec_ch_ua_platform': None,
     'sec_ch_ua_platform_version': None,
     'ua': 'Chrome 97.0.4692.71',
     'ua_class': 'Browser',
     'ua_class_code': 'browser',
     'ua_engine': 'WebKit/Blink',
     'ua_family': 'Chrome',
     'ua_family_code': 'chrome',
     'ua_family_homepage': 'http://www.google.com/chrome/',
     'ua_family_icon': 'chrome.png',
     'ua_family_icon_big': 'chrome_big.png',
     'ua_family_info_url': 'https://udger.com/resources/ua-list/browser-detail?browser=Chrome',
     'ua_family_vendor': 'Google Inc.',
     'ua_family_vendor_code': 'google_inc',
     'ua_family_vendor_homepage': 'https://about.google/',
     'ua_string': '',
     'ua_uptodate_current_version': '107',
     'ua_version': '97.0.4692.71',
     'ua_version_major': '97'}
    >>>     
    >>> result = udger.parse_ip('108.61.199.93')
    >>> pprint(result)
    {'crawler_category': 'Site monitor',
     'crawler_category_code': 'site_monitor',
     'crawler_family': 'PINGOMETER',
     'crawler_family_code': 'pingometer',
     'crawler_family_homepage': '',
     'crawler_family_icon': 'bot_pingometer.png',
     'crawler_family_info_url': 'https://udger.com/resources/ua-list/bot-detail?bot=PINGOMETER',
     'crawler_family_vendor': 'Pingometer, LLC',
     'crawler_family_vendor_code': 'pingometer_llc',
     'crawler_family_vendor_homepage': 'http://pingometer.com/',
     'crawler_last_seen': '2016-09-17 12:15:38',
     'crawler_name': 'PINGOMETER',
     'crawler_respect_robotstxt': 'no',
     'crawler_ver': '',
     'crawler_ver_major': '',
     'datacenter_homepage': 'https://www.choopa.com/',
     'datacenter_name': 'Choopa, LLC.',
     'datacenter_name_code': 'choopa',
     'ip': '108.61.199.93',
     'ip_city': 'Amsterdam',
     'ip_classification': 'Crawler',
     'ip_classification_code': 'crawler',
     'ip_country': 'Netherlands',
     'ip_country_code': 'NL',
     'ip_hostname': '108.61.199.93.vultr.com',
     'ip_last_seen': '2016-09-17 12:00:31',
     'ip_ver': 4}

数据目录

Udger()解析器期望数据文件位于系统临时目录中,该目录由tempfile.gettempdir()返回。

您可以使用如下参数覆盖路径

udger = Udger('/var/cache/udger/')

开发者文档

https://udger.com/pub/documentation/parser/Python-v4/html/

作者

The Udger.com Team (info@udger.com)

v3格式

对于之前的数据格式(v3),请使用https://github.com/udger/udger-python

项目详情


下载文件

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

源分布

udger-v4-5.0.2.tar.gz (15.0 kB 查看哈希值)

上传时间

构建分布

udger_v4-5.0.2-py3-none-any.whl (13.5 kB 查看哈希值)

上传时间 Python 3

支持者