line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Duadua; |
2
|
6
|
|
|
6
|
|
299252
|
use strict; |
|
6
|
|
|
|
|
49
|
|
|
6
|
|
|
|
|
199
|
|
3
|
6
|
|
|
6
|
|
29
|
use warnings; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
138
|
|
4
|
6
|
|
|
6
|
|
1982
|
use Duadua::Parser; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
5685
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.29'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my @PARSER_PROC_LIST = qw/ |
9
|
|
|
|
|
|
|
Duadua::Parser::Browser::MicrosoftEdge |
10
|
|
|
|
|
|
|
Duadua::Parser::Browser::GoogleChrome |
11
|
|
|
|
|
|
|
Duadua::Parser::Browser::MicrosoftInternetExplorer |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Duadua::Parser::Bot::Googlebot |
14
|
|
|
|
|
|
|
Duadua::Parser::Bot::GooglebotMobile |
15
|
|
|
|
|
|
|
Duadua::Parser::Bot::GooglebotAd |
16
|
|
|
|
|
|
|
Duadua::Parser::Bot::GoogleRead |
17
|
|
|
|
|
|
|
Duadua::Parser::Bot::Bingbot |
18
|
|
|
|
|
|
|
Duadua::Parser::Bot::AdIdxBot |
19
|
|
|
|
|
|
|
Duadua::Parser::Bot::BingPreview |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Duadua::Parser::Browser::Opera |
22
|
|
|
|
|
|
|
Duadua::Parser::Browser::MozillaFirefox |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Duadua::Parser::Browser::YahooJapanAppBrowser |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Duadua::Parser::Browser::AppleSafari |
27
|
|
|
|
|
|
|
Duadua::Parser::Browser::Vivaldi |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Duadua::Parser::Bot::Huawei |
30
|
|
|
|
|
|
|
Duadua::Parser::Bot::Sakura |
31
|
|
|
|
|
|
|
Duadua::Parser::HTTPClient::HTTPClient |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Duadua::Parser::Bot::Twitterbot |
34
|
|
|
|
|
|
|
Duadua::Parser::Bot::FacebookCrawler |
35
|
|
|
|
|
|
|
Duadua::Parser::Bot::Slackbot |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Duadua::Parser::Bot::YahooSlurp |
38
|
|
|
|
|
|
|
Duadua::Parser::Bot::Baiduspider |
39
|
|
|
|
|
|
|
Duadua::Parser::Bot::Bytespider |
40
|
|
|
|
|
|
|
Duadua::Parser::Bot::YandexBot |
41
|
|
|
|
|
|
|
Duadua::Parser::Bot::GooglebotMisc |
42
|
|
|
|
|
|
|
Duadua::Parser::Bot::DuckDuckBot |
43
|
|
|
|
|
|
|
Duadua::Parser::Bot::Applebot |
44
|
|
|
|
|
|
|
Duadua::Parser::Bot::Msnbot |
45
|
|
|
|
|
|
|
Duadua::Parser::Bot::BotMisc |
46
|
|
|
|
|
|
|
Duadua::Parser::Bot::Log4Shell |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Duadua::Parser::Browser::GoogleApp |
49
|
|
|
|
|
|
|
Duadua::Parser::Browser::SamsungInternetBrowser |
50
|
|
|
|
|
|
|
Duadua::Parser::Browser::Yandex |
51
|
|
|
|
|
|
|
Duadua::Parser::Browser::DuckDuckGo |
52
|
|
|
|
|
|
|
Duadua::Parser::Bot::OracleGrapeshotCrawler |
53
|
|
|
|
|
|
|
Duadua::Parser::Bot::MailRUBot |
54
|
|
|
|
|
|
|
Duadua::Parser::Browser::PaleMoon |
55
|
|
|
|
|
|
|
Duadua::Parser::Browser::UCBrowser |
56
|
|
|
|
|
|
|
Duadua::Parser::Browser::BrowserMisc |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Duadua::Parser::Bot::YahooJapanBot |
59
|
|
|
|
|
|
|
Duadua::Parser::Bot::HatenaBot |
60
|
|
|
|
|
|
|
Duadua::Parser::Bot::Feedly |
61
|
|
|
|
|
|
|
Duadua::Parser::Bot::Reeder |
62
|
|
|
|
|
|
|
Duadua::Parser::Bot::QuiteRSS |
63
|
|
|
|
|
|
|
Duadua::Parser::Bot::Feedbin |
64
|
|
|
|
|
|
|
Duadua::Parser::Bot::Inoreader |
65
|
|
|
|
|
|
|
Duadua::Parser::Bot::Fastladder |
66
|
|
|
|
|
|
|
Duadua::Parser::Bot::Feedeen |
67
|
|
|
|
|
|
|
Duadua::Parser::Bot::Feedspot |
68
|
|
|
|
|
|
|
Duadua::Parser::Bot::OldReader |
69
|
|
|
|
|
|
|
Duadua::Parser::Bot::Flipboard |
70
|
|
|
|
|
|
|
Duadua::Parser::Bot::Skype |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Duadua::Parser::Browser::Xiaomi |
73
|
|
|
|
|
|
|
Duadua::Parser::FeaturePhone::FeaturePhone |
74
|
|
|
|
|
|
|
Duadua::Parser::Bot::Netcraft |
75
|
|
|
|
|
|
|
Duadua::Parser::Bot::Barkrowler |
76
|
|
|
|
|
|
|
Duadua::Parser::Bot::SMTBot |
77
|
|
|
|
|
|
|
Duadua::Parser::Bot::AdstxtCom |
78
|
|
|
|
|
|
|
Duadua::Parser::Bot::CentroAdsCrawler |
79
|
|
|
|
|
|
|
Duadua::Parser::Bot::LetsEncrypt |
80
|
|
|
|
|
|
|
/; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
for my $parser (@PARSER_PROC_LIST) { |
83
|
|
|
|
|
|
|
eval "require $parser;"; ## no critic |
84
|
|
|
|
|
|
|
die "Could not load $parser, $@" if $@; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub new { |
88
|
419
|
|
|
419
|
1
|
1678004
|
my $class = shift; |
89
|
419
|
|
|
|
|
879
|
my $ua = shift; |
90
|
419
|
|
100
|
|
|
1529
|
my $opt = shift || {}; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
bless { |
93
|
|
|
|
|
|
|
_ua => $class->_get_ua_string($ua), |
94
|
|
|
|
|
|
|
_parsed => 0, |
95
|
|
|
|
|
|
|
_result => {}, |
96
|
|
|
|
|
|
|
_parsers => $class->_build_parsers($opt), |
97
|
|
|
|
|
|
|
_opt_version => $opt->{version}, |
98
|
419
|
|
|
|
|
1071
|
}, $class; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub _build_parsers { |
102
|
419
|
|
|
419
|
|
785
|
my ($class, $opt) = @_; |
103
|
|
|
|
|
|
|
|
104
|
419
|
100
|
|
|
|
1306
|
if (exists $opt->{skip}) { |
105
|
1
|
|
|
|
|
2
|
my @parsers; |
106
|
1
|
|
|
|
|
2
|
for my $p (@PARSER_PROC_LIST) { |
107
|
61
|
100
|
|
|
|
135
|
next if grep { $p eq $_ } @{$opt->{skip}}; |
|
122
|
|
|
|
|
207
|
|
|
61
|
|
|
|
|
80
|
|
108
|
59
|
|
|
|
|
104
|
push @parsers, $p; |
109
|
|
|
|
|
|
|
} |
110
|
1
|
|
|
|
|
9
|
return \@parsers; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
418
|
|
|
|
|
2241
|
return \@PARSER_PROC_LIST; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
336
|
|
|
336
|
1
|
1166
|
sub opt_version { shift->{_opt_version} } |
117
|
|
|
|
|
|
|
|
118
|
412
|
|
|
412
|
1
|
1076
|
sub parsers { shift->{_parsers} } |
119
|
|
|
|
|
|
|
|
120
|
31223
|
|
|
31223
|
1
|
128132
|
sub ua { shift->{_ua} } |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub reparse { |
123
|
6
|
|
|
6
|
1
|
16
|
my ($self, $ua) = @_; |
124
|
|
|
|
|
|
|
|
125
|
6
|
|
|
|
|
17
|
$self->{_ua} = $self->_get_ua_string($ua); |
126
|
6
|
|
|
|
|
16
|
$self->{_result} = {}; |
127
|
|
|
|
|
|
|
|
128
|
6
|
|
|
|
|
19
|
return $self->_parse; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub _result { |
132
|
2282
|
|
|
2282
|
|
4223
|
my ($self, $value) = @_; |
133
|
|
|
|
|
|
|
|
134
|
2282
|
100
|
|
|
|
4310
|
if ($value) { |
135
|
412
|
|
|
|
|
740
|
$self->{_result} = $value; |
136
|
412
|
|
|
|
|
805
|
return $self; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
else { |
139
|
1870
|
100
|
|
|
|
4500
|
$self->parse unless $self->{_parsed}; |
140
|
1870
|
|
|
|
|
11129
|
return $self->{_result}; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub parse { |
145
|
406
|
|
|
406
|
1
|
2081
|
my $self = shift; |
146
|
|
|
|
|
|
|
|
147
|
406
|
100
|
|
|
|
1185
|
if (ref $self eq __PACKAGE__) { |
|
|
100
|
|
|
|
|
|
148
|
402
|
|
|
|
|
857
|
$self->_parse; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
elsif ($self eq __PACKAGE__) { |
151
|
|
|
|
|
|
|
# my $d_obj = Duadua->parse('User-Agent String', $opt); |
152
|
2
|
|
|
|
|
5
|
my $d = __PACKAGE__->new(@_); |
153
|
2
|
|
|
|
|
5
|
return $d->_parse; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
else { |
156
|
|
|
|
|
|
|
# my $d_obj = Duadua::parse('User-Agent String', $opt); |
157
|
2
|
|
|
|
|
8
|
my $d = __PACKAGE__->new($self, @_); |
158
|
2
|
|
|
|
|
5
|
return $d->_parse; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub _parse { |
163
|
412
|
|
|
412
|
|
575
|
my $self = shift; |
164
|
|
|
|
|
|
|
|
165
|
412
|
|
|
|
|
8798
|
$self->_result(Duadua::Parser->parse($self)); |
166
|
412
|
|
|
|
|
698
|
$self->{_parsed} = 1; |
167
|
|
|
|
|
|
|
|
168
|
412
|
|
|
|
|
621
|
return $self; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub _get_ua_string { |
172
|
425
|
|
|
425
|
|
856
|
my ($self, $ua_raw) = @_; |
173
|
|
|
|
|
|
|
|
174
|
425
|
100
|
|
|
|
953
|
if (!defined $ua_raw) { |
175
|
5
|
100
|
66
|
|
|
37
|
return exists $ENV{HTTP_USER_AGENT} && defined $ENV{HTTP_USER_AGENT} ? $ENV{HTTP_USER_AGENT} : ''; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
420
|
100
|
|
|
|
1007
|
if (ref($ua_raw) =~ m!^HTTP::Headers!) { |
179
|
1
|
|
|
|
|
9
|
return $ua_raw->header('User-Agent'); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
419
|
|
|
|
|
1140
|
return $ua_raw; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub name { |
186
|
243
|
|
|
243
|
1
|
685
|
shift->_result->{name}; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub is_bot { |
190
|
241
|
100
|
|
241
|
1
|
137775
|
shift->_result->{is_bot} ? 1 : 0; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub is_ios { |
194
|
241
|
100
|
|
241
|
1
|
133996
|
shift->_result->{is_ios} ? 1 : 0; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub is_android { |
198
|
241
|
100
|
|
241
|
1
|
132855
|
shift->_result->{is_android} ? 1 : 0; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub is_linux { |
202
|
241
|
100
|
|
241
|
1
|
132530
|
shift->_result->{is_linux} ? 1 : 0; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub is_windows { |
206
|
243
|
100
|
|
243
|
1
|
131545
|
shift->_result->{is_windows} ? 1 : 0; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub is_chromeos { |
210
|
238
|
100
|
|
238
|
1
|
131209
|
shift->_result->{is_chromeos} ? 1 : 0; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub version { |
214
|
182
|
100
|
|
182
|
1
|
777
|
shift->_result->{version} || ''; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
1; |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
__END__ |