1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", plugin(clippy))]
#![recursion_limit="100"]
#[macro_use]
extern crate lazy_static;
extern crate regex;
pub mod woothee;
pub mod parser;
pub mod dataset;
use parser::{Parser, WootheeResult};
pub fn is_crawler(agent: &str) -> bool {
if agent.is_empty() || agent == "-" {
return false;
}
let parser = Parser::new();
let mut result = WootheeResult::new();
parser.try_crawler(agent, &mut result)
}
#[test]
fn test_is_crawler_smoke() {
assert!(!is_crawler("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)"));
assert!(is_crawler("Mozilla/5.0 (compatible; Yahoo! Slurp; \
http://help.yahoo.com/help/us/ysearch/slurp)"));
}