chitika/uaparser

语言: Erlang

git: https://github.com/chitika/uaparser

Erlang的用户代理解析器
A user-agent parser for Erlang
README.md (中文)

UAParser

Erlang的用户代理解析器,基于ferd的useragent使用的过程。目前,该库支持:

  • 浏览器识别
  • MSIE,Firefox,Chrome,Opera等等
  • 大多数支持浏览器的版本标识
  • 操作系统识别
  • Windows,Mac OS X,Android,IOS,“Linux”,WebOS等。
  • 以下版本标识: 视窗 Android的 WebOS的 iOS版 Mac OS X.

事实证明,使用的过程比依赖于长序列正则表达式的库有效得多,同时在准确性方面几乎没有损失。

用法

只需使用user-agent作为参数调用函数uaparser:parse / 1,如下所示:

Erlang R16B03 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.4  (abort with ^G)
1> uaparser:parse("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0; SLCC1; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.5.30729; WinTSI 08.02.2010; .NET CLR 3.0.30729; .NET4.0C; BRI/1)").
[{browser,[{name,<<"internet explorer 7">>},
           {family,ie},
           {manufacturer,microsoft},
           {type,web_browser},
           {renderer,trident},
           {version,<<"7.0">>},
           {version_details,[{major,7},{minor,0}]}]},
 {os,[{name,<<"windows vista">>},
      {family,windows},
      {manufacturer,microsoft},
      {type,computer},
      {version,<<"6.0">>},
      {version_details,[{major,6},{minor,0}]}]}]

您将收到嵌套的支持列表,其中包含浏览器和操作系统上提取的信息。

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

UAParser

A user-agent parser for Erlang, based on the process used by ferd's useragent. Currently, this library supports:

  • Browser Identification
  • MSIE, Firefox, Chrome, Opera, and many others
  • Version identification for a majority of support browsers
  • Operating System Identification
  • Windows, Mac OS X, Android, IOS, "Linux", WebOS, and others.
  • Version Identification for the following:
    • Windows
    • Android
    • WebOS
    • iOS
    • Mac OS X

The process used has proven to be significantly more efficient than libraries which rely upon long lists of regular expressions, all the while losing little with respect to accuracy.

Usage

Simply call the function uaparser:parse/1 with the user-agent as its argument, as follows:

Erlang R16B03 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.4  (abort with ^G)
1> uaparser:parse("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0; SLCC1; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.5.30729; WinTSI 08.02.2010; .NET CLR 3.0.30729; .NET4.0C; BRI/1)").
[{browser,[{name,<<"internet explorer 7">>},
           {family,ie},
           {manufacturer,microsoft},
           {type,web_browser},
           {renderer,trident},
           {version,<<"7.0">>},
           {version_details,[{major,7},{minor,0}]}]},
 {os,[{name,<<"windows vista">>},
      {family,windows},
      {manufacturer,microsoft},
      {type,computer},
      {version,<<"6.0">>},
      {version_details,[{major,6},{minor,0}]}]}]

You will receive nested proplists back containing extracted information on both the browser and the operating system.