woothee / woothee-testset
woothee项目测试用例集。Woothee项目是多语言用户代理字符串解析器。
v1.13.0
2021-10-31 04:01 UTC
README
Woothee项目是多语言用户代理字符串解析器。
您可以在演示网站上尝试: http://woothee.github.io/
为什么有新的项目?
我们需要在两种或多种编程语言中实现相同的逻辑,以便在各个框架、中间件和环境中使用。
本项目最重要的数据是一组返回值和一组测试用例,用于确保不同语言实现的结果一致性。
实现
版本
- v1.13.0
- 添加Android操作系统版本(Android 11~)
- v1.12.0
- 添加三星浏览器
- 添加谷歌的AdsBot
- v1.11.1
- 更新测试集中的GSA版本
- v1.11.0
- 添加谷歌搜索应用
- v1.10.0
- 添加基于Chromium的微软Edge,Edge for iOS/Android
- v1.9.0
- 添加Android 9
- v1.8.0
- 添加Yandex浏览器
- v1.7.0
- 添加trendictionbot爬虫
- 添加Yeti 1.1爬虫用户代理测试
- v1.6.0
- 添加Android Webview
- 添加curl HTTP库
- v1.5.0
- 添加BingPreview爬虫
- v1.4.0
- 添加Vivaldi
- v1.3.0
- 添加iOS的Firefox
- v1.2.1
- 修复测试集中BlackBerry 10的bug
- v1.2.0
- 添加微软Edge,手机Webview
- 添加Windows 10,BlackBerry 10
- 添加Twitterbot
- v1.1.0
- 添加空输入数据的规范
- v1.0.1
- 添加MSIE11的变体
- v1.0.0
- 某些实现尚未达到v1版本。
版本号的使用方法:
- vX.Y.Z
- X和Y是主版本/次版本号,用于控制数据集/测试集的规范
- Z是每个语言实现版本控制的补丁号
- Z也用于测试集的bug修复控制(每个语言实现的版本也应该升级)
实现
- Java(以及Hive UDF)
- Perl
- Ruby
- Python
- JavaScript(Node.js或浏览器)
- PHP
- Golang
- Rust
概要
在Java中:(使用java/woothee.jar)
// import is.tagomor.woothee.Classifier; // import is.tagomor.woothee.DataSet; Map r = Classifier.parse("user agent string"); r.get("name") // => name of browser (or string like name of user-agent) r.get("category") // => "pc", "smartphone", "mobilephone", "appliance", "crawler", "misc", "unknown" r.get("os") // => os from user-agent, or carrier name of mobile phones r.get("version"); // => version of browser, or terminal type name of mobile phones r.get("os_version"); // => "NT 6.3" (for Windows), "10.8.3" (for OSX), "8.0.1" (for iOS), ....
在Hive中:(将woothee.jar复制到您的CLASSPATH中,并创建函数)
-- add jar to classpath add jar woothee.jar; -- create function CREATE TEMPORARY FUNCTION parse_agent as 'is.tagomor.woothee.hive.ParseAgent'; -- count visits of bots SELECT parsed_agent['name'] AS botname, COUNT(*) AS cnt FROM ( SELECT parse_agent(user_agent) AS parsed_agent FROM table_name WHERE date='today' ) x WHERE parsed_agent['category'] = 'crawler' GROUP BY parsed_agent['name'] ORDER BY cnt DESC LIMIT 1000;
在Perl中:(cpanm Woothee)
use Woothee; Woothee::parse("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)"); # => {'name'=>"Internet Explorer", 'category'=>"pc", 'os'=>"Windows 7", 'version'=>"8.0", 'vendor'=>"Microsoft", 'os_version'=>"NT 6.1"}
在Ruby中:(gem install woothee)
require 'woothee' Woothee.parse("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)") # => {:name=>"Internet Explorer", :category=>:pc, :os=>"Windows 7", :version=>"8.0", :vendor=>"Microsoft", :os_version=>"NT 6.1"}
在Python中
import woothee woothee.parse("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)") # => {'name': 'Internet Explorer', 'category': 'pc', 'os': 'Windows 7', 'version': '8.0', 'vendor': 'Microsoft'}
在JavaScript中(HTML,从release/woothee.js复制)
<script src="./your/own/path/woothee.js"></script> <script> woothee.parse('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)') // => {name: 'Internet Explorer', category: 'pc', os: 'Windows 7', version: '8.0', vendor: 'Microsoft', os_version: 'NT 6.1'} </script>
在Node.js中(npm install woothee)
var woothee = require('woothee'); woothee.parse('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)') // => {name: 'Internet Explorer', category: 'pc', os: 'Windows 7', version: '8.0', vendor: 'Microsoft', os_version: 'NT 6.1'}
在PHP中(composer require woothee/woothee:*)
<?php include __DIR__ . '/vendor/autoload.php'; $classifier = new \Woothee\Classifier; $classifier->parse('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)'); // => ['name' => 'Internet Explorer', 'category' => 'pc', 'os' => 'Windows 7', 'version' => '8.0', 'vendor' => 'Microsoft']
在Rust中
extern crate woothee; use woothee::parser::Parser; fn main() { let parser = Parser::new(); let result = parser.parse("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)"); println!("{:?}", result); } // => Some(WootheeResult { name: "Internet Explorer", category: "pc", os: "Windows 7", os_version: "NT 6.1", browser_type: "UNKNOWN", version: "8.0", vendor: "Microsoft" })
待办事项
- 'mobilephone'表示日本移动手机群组
- 对于多区域代码,需要国内模式指定符(或其他机制)
常见问题解答
- 什么是Woothee?
作者
- TAGOMORI Satoshi tagomoris@gmail.com
许可证
版权 2012- TAGOMORI Satoshi (tagomoris)
遵循Apache许可证2.0版(以下简称“许可证”);除非遵守许可证或书面同意,否则不得使用此文件。您可以在以下地址获得许可证副本:
https://apache.ac.cn/licenses/LICENSE-2.0
除非适用法律要求或书面同意,否则在许可证下分发的软件按“原样”基础分发,不提供任何明示或暗示的保证或条件。有关许可证具体规定权限和限制,请参阅许可证。