line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Woothee; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
296109
|
use strict; |
|
6
|
|
|
|
|
48
|
|
|
6
|
|
|
|
|
186
|
|
4
|
6
|
|
|
6
|
|
31
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
137
|
|
5
|
6
|
|
|
6
|
|
29
|
use Carp; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
305
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
2698
|
use Woothee::DataSet; |
|
6
|
|
|
|
|
26
|
|
|
6
|
|
|
|
|
361
|
|
8
|
6
|
|
|
6
|
|
2467
|
use Woothee::Browser; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
189
|
|
9
|
6
|
|
|
6
|
|
2526
|
use Woothee::OS; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
190
|
|
10
|
6
|
|
|
6
|
|
2375
|
use Woothee::MobilePhone; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
198
|
|
11
|
6
|
|
|
6
|
|
2496
|
use Woothee::Crawler; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
190
|
|
12
|
6
|
|
|
6
|
|
2286
|
use Woothee::Appliance; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
174
|
|
13
|
6
|
|
|
6
|
|
2352
|
use Woothee::Misc; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
200
|
|
14
|
|
|
|
|
|
|
|
15
|
6
|
|
|
6
|
|
2611
|
use version; |
|
6
|
|
|
|
|
11213
|
|
|
6
|
|
|
|
|
32
|
|
16
|
|
|
|
|
|
|
our $VERSION = "v1.10.0"; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub parse { |
19
|
735
|
|
|
735
|
1
|
1926578
|
my ($this,$useragent) = @_; |
20
|
735
|
|
66
|
|
|
3038
|
$useragent ||= $this; # called as Woothee::parse() |
21
|
735
|
|
|
|
|
1545
|
return fill_result(exec_parse($useragent)); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub is_crawler { |
25
|
735
|
|
|
735
|
1
|
1429373
|
my ($this,$useragent) = @_; |
26
|
735
|
|
66
|
|
|
2802
|
$useragent ||= $this; # called as Woothee::is_crawler() |
27
|
|
|
|
|
|
|
|
28
|
735
|
0
|
33
|
|
|
1832
|
return 0 if not defined($useragent) || length($useragent) < 1 || $useragent eq '-'; |
|
|
|
33
|
|
|
|
|
29
|
735
|
100
|
|
|
|
1597
|
if (try_crawler($useragent, {})) { |
30
|
168
|
|
|
|
|
480
|
return 1; |
31
|
|
|
|
|
|
|
} |
32
|
567
|
|
|
|
|
1801
|
return 0; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub exec_parse { |
36
|
735
|
|
|
735
|
0
|
1149
|
my $useragent = shift; |
37
|
735
|
|
|
|
|
1172
|
my $result = {}; |
38
|
|
|
|
|
|
|
|
39
|
735
|
0
|
33
|
|
|
1926
|
return $result if not defined($useragent) || length($useragent) < 1 || $useragent eq '-'; |
|
|
|
33
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
735
|
100
|
|
|
|
1608
|
if (try_crawler($useragent, $result)) { |
42
|
168
|
|
|
|
|
373
|
return $result; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
567
|
100
|
|
|
|
1343
|
if (try_browser($useragent, $result)) { |
46
|
234
|
50
|
|
|
|
544
|
if (try_os($useragent, $result)) { |
47
|
234
|
|
|
|
|
645
|
return $result; |
48
|
|
|
|
|
|
|
}else{ |
49
|
0
|
|
|
|
|
0
|
return $result; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
333
|
100
|
|
|
|
736
|
if (try_mobilephone($useragent, $result)) { |
54
|
78
|
|
|
|
|
214
|
return $result; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
255
|
100
|
|
|
|
501
|
if (try_appliance($useragent, $result)) { |
58
|
33
|
|
|
|
|
87
|
return $result; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
222
|
100
|
|
|
|
466
|
if (try_misc($useragent, $result)) { |
62
|
9
|
|
|
|
|
27
|
return $result; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# browser unknown. check os only |
66
|
213
|
100
|
|
|
|
468
|
if (try_os($useragent, $result)) { |
67
|
45
|
|
|
|
|
127
|
return $result; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
168
|
50
|
|
|
|
321
|
if (try_rare_cases($useragent, $result)) { |
71
|
168
|
|
|
|
|
445
|
return $result; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
0
|
return $result; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub try_crawler { |
78
|
1470
|
|
|
1470
|
0
|
2657
|
my ($useragent, $result) = @_; |
79
|
|
|
|
|
|
|
|
80
|
1470
|
100
|
|
|
|
3996
|
if (Woothee::Crawler::challenge_google($useragent, $result)) { |
81
|
54
|
|
|
|
|
124
|
return 1; |
82
|
|
|
|
|
|
|
} |
83
|
1416
|
100
|
|
|
|
3594
|
if (Woothee::Crawler::challenge_crawlers($useragent, $result)) { |
84
|
282
|
|
|
|
|
635
|
return 1; |
85
|
|
|
|
|
|
|
} |
86
|
1134
|
|
|
|
|
2399
|
return 0; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub try_browser { |
90
|
567
|
|
|
567
|
0
|
1098
|
my ($useragent, $result) = @_; |
91
|
|
|
|
|
|
|
|
92
|
567
|
100
|
|
|
|
1680
|
if (Woothee::Browser::challenge_msie($useragent, $result)) { |
93
|
66
|
|
|
|
|
168
|
return 1; |
94
|
|
|
|
|
|
|
} |
95
|
501
|
100
|
|
|
|
1334
|
if (Woothee::Browser::challenge_vivaldi($useragent, $result)) { |
96
|
9
|
|
|
|
|
29
|
return 1; |
97
|
|
|
|
|
|
|
} |
98
|
492
|
100
|
|
|
|
1166
|
if (Woothee::Browser::challenge_yandex_browser($useragent, $result)) { |
99
|
6
|
|
|
|
|
24
|
return 1; |
100
|
|
|
|
|
|
|
} |
101
|
486
|
100
|
|
|
|
1186
|
if (Woothee::Browser::challenge_safari_chrome($useragent, $result)) { |
102
|
84
|
|
|
|
|
221
|
return 1; |
103
|
|
|
|
|
|
|
} |
104
|
402
|
100
|
|
|
|
948
|
if (Woothee::Browser::challenge_firefox($useragent, $result)) { |
105
|
27
|
|
|
|
|
74
|
return 1; |
106
|
|
|
|
|
|
|
} |
107
|
375
|
100
|
|
|
|
901
|
if (Woothee::Browser::challenge_opera($useragent, $result)) { |
108
|
30
|
|
|
|
|
82
|
return 1; |
109
|
|
|
|
|
|
|
} |
110
|
345
|
100
|
|
|
|
785
|
if (Woothee::Browser::challenge_webview($useragent, $result)) { |
111
|
12
|
|
|
|
|
33
|
return 1; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
333
|
|
|
|
|
690
|
return 0; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub try_os { |
118
|
447
|
|
|
447
|
0
|
807
|
my ($useragent, $result) = @_; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# Windows PC, and Windows Phone OS |
121
|
447
|
100
|
|
|
|
1118
|
if (Woothee::OS::challenge_windows($useragent, $result)) { |
122
|
99
|
|
|
|
|
244
|
return 1; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# OSX PC and iOS devices(strict check) |
126
|
348
|
100
|
|
|
|
815
|
if (Woothee::OS::challenge_osx($useragent, $result)) { |
127
|
57
|
|
|
|
|
147
|
return 1; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# Linux PC, and Android |
131
|
291
|
100
|
|
|
|
667
|
if (Woothee::OS::challenge_linux($useragent, $result)) { |
132
|
45
|
|
|
|
|
113
|
return 1; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# all useragents matches /(iPhone|iPad|iPod|Android|BlackBerry)/ |
136
|
246
|
100
|
|
|
|
597
|
if (Woothee::OS::challenge_smartphone($useragent, $result)) { |
137
|
36
|
|
|
|
|
92
|
return 1; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# mobile phones like KDDI-.* |
141
|
210
|
100
|
|
|
|
531
|
if (Woothee::OS::challenge_mobilephone($useragent, $result)) { |
142
|
18
|
|
|
|
|
47
|
return 1; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# Nintendo DSi/Wii with Opera |
146
|
192
|
100
|
|
|
|
406
|
if (Woothee::OS::challenge_appliance($useragent, $result)) { |
147
|
6
|
|
|
|
|
16
|
return 1; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# Win98, BSD |
151
|
186
|
100
|
|
|
|
481
|
if (Woothee::OS::challenge_misc($useragent, $result)) { |
152
|
18
|
|
|
|
|
47
|
return 1; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
168
|
|
|
|
|
352
|
return 0; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub try_mobilephone { |
159
|
333
|
|
|
333
|
0
|
630
|
my ($useragent, $result) = @_; |
160
|
|
|
|
|
|
|
|
161
|
333
|
100
|
|
|
|
893
|
if (Woothee::MobilePhone::challenge_docomo($useragent, $result)) { |
162
|
18
|
|
|
|
|
55
|
return 1; |
163
|
|
|
|
|
|
|
} |
164
|
315
|
100
|
|
|
|
760
|
if (Woothee::MobilePhone::challenge_au($useragent, $result)) { |
165
|
6
|
|
|
|
|
19
|
return 1; |
166
|
|
|
|
|
|
|
} |
167
|
309
|
100
|
|
|
|
741
|
if (Woothee::MobilePhone::challenge_softbank($useragent, $result)) { |
168
|
21
|
|
|
|
|
54
|
return 1; |
169
|
|
|
|
|
|
|
} |
170
|
288
|
100
|
|
|
|
644
|
if (Woothee::MobilePhone::challenge_willcom($useragent, $result)) { |
171
|
9
|
|
|
|
|
27
|
return 1; |
172
|
|
|
|
|
|
|
} |
173
|
279
|
100
|
|
|
|
640
|
if (Woothee::MobilePhone::challenge_misc($useragent, $result)) { |
174
|
24
|
|
|
|
|
57
|
return 1; |
175
|
|
|
|
|
|
|
} |
176
|
255
|
|
|
|
|
515
|
return 0; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub try_appliance { |
180
|
255
|
|
|
255
|
0
|
433
|
my ($useragent, $result) = @_; |
181
|
|
|
|
|
|
|
|
182
|
255
|
100
|
|
|
|
673
|
if (Woothee::Appliance::challenge_playstation($useragent, $result)) { |
183
|
15
|
|
|
|
|
46
|
return 1; |
184
|
|
|
|
|
|
|
} |
185
|
240
|
100
|
|
|
|
583
|
if (Woothee::Appliance::challenge_nintendo($useragent, $result)) { |
186
|
6
|
|
|
|
|
22
|
return 1; |
187
|
|
|
|
|
|
|
} |
188
|
234
|
100
|
|
|
|
535
|
if (Woothee::Appliance::challenge_digitaltv($useragent, $result)) { |
189
|
12
|
|
|
|
|
32
|
return 1; |
190
|
|
|
|
|
|
|
} |
191
|
222
|
|
|
|
|
429
|
return 0; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub try_misc { |
195
|
222
|
|
|
222
|
0
|
352
|
my ($useragent, $result) = @_; |
196
|
|
|
|
|
|
|
|
197
|
222
|
100
|
|
|
|
593
|
if (Woothee::Misc::challenge_desktoptools($useragent, $result)) { |
198
|
9
|
|
|
|
|
31
|
return 1; |
199
|
|
|
|
|
|
|
} |
200
|
213
|
|
|
|
|
451
|
return 0; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub try_rare_cases { |
204
|
168
|
|
|
168
|
0
|
284
|
my ($useragent, $result) = @_; |
205
|
|
|
|
|
|
|
|
206
|
168
|
50
|
|
|
|
384
|
if (Woothee::Misc::challenge_smartphone_patterns($useragent, $result)) { |
207
|
0
|
|
|
|
|
0
|
return 1; |
208
|
|
|
|
|
|
|
} |
209
|
168
|
100
|
|
|
|
446
|
if (Woothee::Browser::challenge_sleipnir($useragent, $result)) { |
210
|
3
|
|
|
|
|
10
|
return 1; |
211
|
|
|
|
|
|
|
} |
212
|
165
|
100
|
|
|
|
371
|
if (Woothee::Misc::challenge_http_library($useragent, $result)) { |
213
|
78
|
|
|
|
|
211
|
return 1; |
214
|
|
|
|
|
|
|
} |
215
|
87
|
100
|
|
|
|
211
|
if (Woothee::Misc::challenge_maybe_rss_reader($useragent, $result)) { |
216
|
18
|
|
|
|
|
49
|
return 1; |
217
|
|
|
|
|
|
|
} |
218
|
69
|
50
|
|
|
|
186
|
if (Woothee::Crawler::challenge_maybe_crawler($useragent, $result)) { |
219
|
69
|
|
|
|
|
161
|
return 1; |
220
|
|
|
|
|
|
|
} |
221
|
0
|
|
|
|
|
0
|
return 0; |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
my @filled = ( |
225
|
|
|
|
|
|
|
Woothee::DataSet->const('ATTRIBUTE_NAME') => Woothee::DataSet->const('VALUE_UNKNOWN'), |
226
|
|
|
|
|
|
|
Woothee::DataSet->const('ATTRIBUTE_CATEGORY') => Woothee::DataSet->const('VALUE_UNKNOWN'), |
227
|
|
|
|
|
|
|
Woothee::DataSet->const('ATTRIBUTE_OS') => Woothee::DataSet->const('VALUE_UNKNOWN'), |
228
|
|
|
|
|
|
|
Woothee::DataSet->const('ATTRIBUTE_OS_VERSION') => Woothee::DataSet->const('VALUE_UNKNOWN'), |
229
|
|
|
|
|
|
|
Woothee::DataSet->const('ATTRIBUTE_VERSION') => Woothee::DataSet->const('VALUE_UNKNOWN'), |
230
|
|
|
|
|
|
|
Woothee::DataSet->const('ATTRIBUTE_VENDOR') => Woothee::DataSet->const('VALUE_UNKNOWN'), |
231
|
|
|
|
|
|
|
); |
232
|
|
|
|
|
|
|
sub fill_result { |
233
|
735
|
|
|
735
|
0
|
1151
|
my $result = shift; |
234
|
735
|
|
|
|
|
5610
|
return +{@filled, %$result}; |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
1; |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
__END__ |