| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Woothee; |
|
2
|
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
262228
|
use strict; |
|
|
6
|
|
|
|
|
45
|
|
|
|
6
|
|
|
|
|
172
|
|
|
4
|
6
|
|
|
6
|
|
26
|
use warnings; |
|
|
6
|
|
|
|
|
8
|
|
|
|
6
|
|
|
|
|
117
|
|
|
5
|
6
|
|
|
6
|
|
22
|
use Carp; |
|
|
6
|
|
|
|
|
9
|
|
|
|
6
|
|
|
|
|
267
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
2291
|
use Woothee::DataSet; |
|
|
6
|
|
|
|
|
33
|
|
|
|
6
|
|
|
|
|
271
|
|
|
8
|
6
|
|
|
6
|
|
2194
|
use Woothee::Browser; |
|
|
6
|
|
|
|
|
12
|
|
|
|
6
|
|
|
|
|
157
|
|
|
9
|
6
|
|
|
6
|
|
2138
|
use Woothee::OS; |
|
|
6
|
|
|
|
|
12
|
|
|
|
6
|
|
|
|
|
189
|
|
|
10
|
6
|
|
|
6
|
|
2086
|
use Woothee::MobilePhone; |
|
|
6
|
|
|
|
|
13
|
|
|
|
6
|
|
|
|
|
167
|
|
|
11
|
6
|
|
|
6
|
|
2088
|
use Woothee::Crawler; |
|
|
6
|
|
|
|
|
15
|
|
|
|
6
|
|
|
|
|
154
|
|
|
12
|
6
|
|
|
6
|
|
2039
|
use Woothee::Appliance; |
|
|
6
|
|
|
|
|
15
|
|
|
|
6
|
|
|
|
|
145
|
|
|
13
|
6
|
|
|
6
|
|
2016
|
use Woothee::Misc; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
4945
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = "1.8.0"; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub parse { |
|
18
|
723
|
|
|
723
|
1
|
1574438
|
my ($this,$useragent) = @_; |
|
19
|
723
|
|
66
|
|
|
2553
|
$useragent ||= $this; # called as Woothee::parse() |
|
20
|
723
|
|
|
|
|
1257
|
return fill_result(exec_parse($useragent)); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub is_crawler { |
|
24
|
723
|
|
|
723
|
1
|
1170770
|
my ($this,$useragent) = @_; |
|
25
|
723
|
|
66
|
|
|
2247
|
$useragent ||= $this; # called as Woothee::is_crawler() |
|
26
|
|
|
|
|
|
|
|
|
27
|
723
|
0
|
33
|
|
|
1435
|
return 0 if not defined($useragent) || length($useragent) < 1 || $useragent eq '-'; |
|
|
|
|
33
|
|
|
|
|
|
28
|
723
|
100
|
|
|
|
1209
|
if (try_crawler($useragent, {})) { |
|
29
|
168
|
|
|
|
|
385
|
return 1; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
555
|
|
|
|
|
1448
|
return 0; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub exec_parse { |
|
35
|
723
|
|
|
723
|
0
|
985
|
my $useragent = shift; |
|
36
|
723
|
|
|
|
|
1023
|
my $result = {}; |
|
37
|
|
|
|
|
|
|
|
|
38
|
723
|
0
|
33
|
|
|
1568
|
return $result if not defined($useragent) || length($useragent) < 1 || $useragent eq '-'; |
|
|
|
|
33
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
723
|
100
|
|
|
|
1147
|
if (try_crawler($useragent, $result)) { |
|
41
|
168
|
|
|
|
|
333
|
return $result; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
555
|
100
|
|
|
|
926
|
if (try_browser($useragent, $result)) { |
|
45
|
222
|
50
|
|
|
|
450
|
if (try_os($useragent, $result)) { |
|
46
|
222
|
|
|
|
|
514
|
return $result; |
|
47
|
|
|
|
|
|
|
}else{ |
|
48
|
0
|
|
|
|
|
0
|
return $result; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
333
|
100
|
|
|
|
921
|
if (try_mobilephone($useragent, $result)) { |
|
53
|
78
|
|
|
|
|
168
|
return $result; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
255
|
100
|
|
|
|
419
|
if (try_appliance($useragent, $result)) { |
|
57
|
33
|
|
|
|
|
70
|
return $result; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
222
|
100
|
|
|
|
359
|
if (try_misc($useragent, $result)) { |
|
61
|
9
|
|
|
|
|
21
|
return $result; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# browser unknown. check os only |
|
65
|
213
|
100
|
|
|
|
345
|
if (try_os($useragent, $result)) { |
|
66
|
45
|
|
|
|
|
96
|
return $result; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
168
|
50
|
|
|
|
284
|
if (try_rare_cases($useragent, $result)) { |
|
70
|
168
|
|
|
|
|
337
|
return $result; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
0
|
return $result; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub try_crawler { |
|
77
|
1446
|
|
|
1446
|
0
|
2040
|
my ($useragent, $result) = @_; |
|
78
|
|
|
|
|
|
|
|
|
79
|
1446
|
100
|
|
|
|
2769
|
if (Woothee::Crawler::challenge_google($useragent, $result)) { |
|
80
|
54
|
|
|
|
|
95
|
return 1; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
1392
|
100
|
|
|
|
2688
|
if (Woothee::Crawler::challenge_crawlers($useragent, $result)) { |
|
83
|
282
|
|
|
|
|
514
|
return 1; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
1110
|
|
|
|
|
1889
|
return 0; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub try_browser { |
|
89
|
555
|
|
|
555
|
0
|
824
|
my ($useragent, $result) = @_; |
|
90
|
|
|
|
|
|
|
|
|
91
|
555
|
100
|
|
|
|
1216
|
if (Woothee::Browser::challenge_msie($useragent, $result)) { |
|
92
|
66
|
|
|
|
|
160
|
return 1; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
489
|
100
|
|
|
|
1017
|
if (Woothee::Browser::challenge_vivaldi($useragent, $result)) { |
|
95
|
9
|
|
|
|
|
24
|
return 1; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
480
|
100
|
|
|
|
928
|
if (Woothee::Browser::challenge_yandex_browser($useragent, $result)) { |
|
98
|
6
|
|
|
|
|
15
|
return 1; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
474
|
100
|
|
|
|
951
|
if (Woothee::Browser::challenge_safari_chrome($useragent, $result)) { |
|
101
|
72
|
|
|
|
|
173
|
return 1; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
402
|
100
|
|
|
|
766
|
if (Woothee::Browser::challenge_firefox($useragent, $result)) { |
|
104
|
27
|
|
|
|
|
69
|
return 1; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
375
|
100
|
|
|
|
673
|
if (Woothee::Browser::challenge_opera($useragent, $result)) { |
|
107
|
30
|
|
|
|
|
80
|
return 1; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
345
|
100
|
|
|
|
620
|
if (Woothee::Browser::challenge_webview($useragent, $result)) { |
|
110
|
12
|
|
|
|
|
28
|
return 1; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
333
|
|
|
|
|
600
|
return 0; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub try_os { |
|
117
|
435
|
|
|
435
|
0
|
618
|
my ($useragent, $result) = @_; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Windows PC, and Windows Phone OS |
|
120
|
435
|
100
|
|
|
|
906
|
if (Woothee::OS::challenge_windows($useragent, $result)) { |
|
121
|
96
|
|
|
|
|
191
|
return 1; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# OSX PC and iOS devices(strict check) |
|
125
|
339
|
100
|
|
|
|
632
|
if (Woothee::OS::challenge_osx($useragent, $result)) { |
|
126
|
54
|
|
|
|
|
119
|
return 1; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# Linux PC, and Android |
|
130
|
285
|
100
|
|
|
|
536
|
if (Woothee::OS::challenge_linux($useragent, $result)) { |
|
131
|
39
|
|
|
|
|
91
|
return 1; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# all useragents matches /(iPhone|iPad|iPod|Android|BlackBerry)/ |
|
135
|
246
|
100
|
|
|
|
469
|
if (Woothee::OS::challenge_smartphone($useragent, $result)) { |
|
136
|
36
|
|
|
|
|
80
|
return 1; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# mobile phones like KDDI-.* |
|
140
|
210
|
100
|
|
|
|
409
|
if (Woothee::OS::challenge_mobilephone($useragent, $result)) { |
|
141
|
18
|
|
|
|
|
43
|
return 1; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# Nintendo DSi/Wii with Opera |
|
145
|
192
|
100
|
|
|
|
366
|
if (Woothee::OS::challenge_appliance($useragent, $result)) { |
|
146
|
6
|
|
|
|
|
13
|
return 1; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# Win98, BSD |
|
150
|
186
|
100
|
|
|
|
358
|
if (Woothee::OS::challenge_misc($useragent, $result)) { |
|
151
|
18
|
|
|
|
|
42
|
return 1; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
168
|
|
|
|
|
288
|
return 0; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub try_mobilephone { |
|
158
|
333
|
|
|
333
|
0
|
490
|
my ($useragent, $result) = @_; |
|
159
|
|
|
|
|
|
|
|
|
160
|
333
|
100
|
|
|
|
724
|
if (Woothee::MobilePhone::challenge_docomo($useragent, $result)) { |
|
161
|
18
|
|
|
|
|
40
|
return 1; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
315
|
100
|
|
|
|
588
|
if (Woothee::MobilePhone::challenge_au($useragent, $result)) { |
|
164
|
6
|
|
|
|
|
18
|
return 1; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
309
|
100
|
|
|
|
924
|
if (Woothee::MobilePhone::challenge_softbank($useragent, $result)) { |
|
167
|
21
|
|
|
|
|
48
|
return 1; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
288
|
100
|
|
|
|
535
|
if (Woothee::MobilePhone::challenge_willcom($useragent, $result)) { |
|
170
|
9
|
|
|
|
|
24
|
return 1; |
|
171
|
|
|
|
|
|
|
} |
|
172
|
279
|
100
|
|
|
|
539
|
if (Woothee::MobilePhone::challenge_misc($useragent, $result)) { |
|
173
|
24
|
|
|
|
|
52
|
return 1; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
255
|
|
|
|
|
422
|
return 0; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub try_appliance { |
|
179
|
255
|
|
|
255
|
0
|
364
|
my ($useragent, $result) = @_; |
|
180
|
|
|
|
|
|
|
|
|
181
|
255
|
100
|
|
|
|
523
|
if (Woothee::Appliance::challenge_playstation($useragent, $result)) { |
|
182
|
15
|
|
|
|
|
35
|
return 1; |
|
183
|
|
|
|
|
|
|
} |
|
184
|
240
|
100
|
|
|
|
485
|
if (Woothee::Appliance::challenge_nintendo($useragent, $result)) { |
|
185
|
6
|
|
|
|
|
18
|
return 1; |
|
186
|
|
|
|
|
|
|
} |
|
187
|
234
|
100
|
|
|
|
413
|
if (Woothee::Appliance::challenge_digitaltv($useragent, $result)) { |
|
188
|
12
|
|
|
|
|
28
|
return 1; |
|
189
|
|
|
|
|
|
|
} |
|
190
|
222
|
|
|
|
|
361
|
return 0; |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub try_misc { |
|
194
|
222
|
|
|
222
|
0
|
304
|
my ($useragent, $result) = @_; |
|
195
|
|
|
|
|
|
|
|
|
196
|
222
|
100
|
|
|
|
423
|
if (Woothee::Misc::challenge_desktoptools($useragent, $result)) { |
|
197
|
9
|
|
|
|
|
22
|
return 1; |
|
198
|
|
|
|
|
|
|
} |
|
199
|
213
|
|
|
|
|
352
|
return 0; |
|
200
|
|
|
|
|
|
|
} |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub try_rare_cases { |
|
203
|
168
|
|
|
168
|
0
|
227
|
my ($useragent, $result) = @_; |
|
204
|
|
|
|
|
|
|
|
|
205
|
168
|
50
|
|
|
|
297
|
if (Woothee::Misc::challenge_smartphone_patterns($useragent, $result)) { |
|
206
|
0
|
|
|
|
|
0
|
return 1; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
168
|
100
|
|
|
|
356
|
if (Woothee::Browser::challenge_sleipnir($useragent, $result)) { |
|
209
|
3
|
|
|
|
|
12
|
return 1; |
|
210
|
|
|
|
|
|
|
} |
|
211
|
165
|
100
|
|
|
|
300
|
if (Woothee::Misc::challenge_http_library($useragent, $result)) { |
|
212
|
78
|
|
|
|
|
171
|
return 1; |
|
213
|
|
|
|
|
|
|
} |
|
214
|
87
|
100
|
|
|
|
162
|
if (Woothee::Misc::challenge_maybe_rss_reader($useragent, $result)) { |
|
215
|
18
|
|
|
|
|
40
|
return 1; |
|
216
|
|
|
|
|
|
|
} |
|
217
|
69
|
50
|
|
|
|
153
|
if (Woothee::Crawler::challenge_maybe_crawler($useragent, $result)) { |
|
218
|
69
|
|
|
|
|
134
|
return 1; |
|
219
|
|
|
|
|
|
|
} |
|
220
|
0
|
|
|
|
|
0
|
return 0; |
|
221
|
|
|
|
|
|
|
} |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
my @filled = ( |
|
224
|
|
|
|
|
|
|
Woothee::DataSet->const('ATTRIBUTE_NAME') => Woothee::DataSet->const('VALUE_UNKNOWN'), |
|
225
|
|
|
|
|
|
|
Woothee::DataSet->const('ATTRIBUTE_CATEGORY') => Woothee::DataSet->const('VALUE_UNKNOWN'), |
|
226
|
|
|
|
|
|
|
Woothee::DataSet->const('ATTRIBUTE_OS') => Woothee::DataSet->const('VALUE_UNKNOWN'), |
|
227
|
|
|
|
|
|
|
Woothee::DataSet->const('ATTRIBUTE_OS_VERSION') => Woothee::DataSet->const('VALUE_UNKNOWN'), |
|
228
|
|
|
|
|
|
|
Woothee::DataSet->const('ATTRIBUTE_VERSION') => Woothee::DataSet->const('VALUE_UNKNOWN'), |
|
229
|
|
|
|
|
|
|
Woothee::DataSet->const('ATTRIBUTE_VENDOR') => Woothee::DataSet->const('VALUE_UNKNOWN'), |
|
230
|
|
|
|
|
|
|
); |
|
231
|
|
|
|
|
|
|
sub fill_result { |
|
232
|
723
|
|
|
723
|
0
|
939
|
my $result = shift; |
|
233
|
723
|
|
|
|
|
4281
|
return +{@filled, %$result}; |
|
234
|
|
|
|
|
|
|
} |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
1; |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
__END__ |