line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Duadua; |
2
|
6
|
|
|
6
|
|
276217
|
use strict; |
|
6
|
|
|
|
|
49
|
|
|
6
|
|
|
|
|
200
|
|
3
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
153
|
|
4
|
6
|
|
|
6
|
|
2036
|
use Duadua::Parser; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
4903
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.27'; |
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::YandexBot |
40
|
|
|
|
|
|
|
Duadua::Parser::Bot::GooglebotMisc |
41
|
|
|
|
|
|
|
Duadua::Parser::Bot::DuckDuckBot |
42
|
|
|
|
|
|
|
Duadua::Parser::Bot::Applebot |
43
|
|
|
|
|
|
|
Duadua::Parser::Bot::Msnbot |
44
|
|
|
|
|
|
|
Duadua::Parser::Bot::BotMisc |
45
|
|
|
|
|
|
|
Duadua::Parser::Bot::Log4Shell |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Duadua::Parser::Browser::GoogleApp |
48
|
|
|
|
|
|
|
Duadua::Parser::Browser::SamsungInternetBrowser |
49
|
|
|
|
|
|
|
Duadua::Parser::Browser::Yandex |
50
|
|
|
|
|
|
|
Duadua::Parser::Browser::DuckDuckGo |
51
|
|
|
|
|
|
|
Duadua::Parser::Bot::OracleGrapeshotCrawler |
52
|
|
|
|
|
|
|
Duadua::Parser::Bot::MailRUBot |
53
|
|
|
|
|
|
|
Duadua::Parser::Browser::PaleMoon |
54
|
|
|
|
|
|
|
Duadua::Parser::Browser::UCBrowser |
55
|
|
|
|
|
|
|
Duadua::Parser::Browser::BrowserMisc |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Duadua::Parser::Bot::YahooJapanBot |
58
|
|
|
|
|
|
|
Duadua::Parser::Bot::HatenaBot |
59
|
|
|
|
|
|
|
Duadua::Parser::Bot::Feedly |
60
|
|
|
|
|
|
|
Duadua::Parser::Bot::Reeder |
61
|
|
|
|
|
|
|
Duadua::Parser::Bot::QuiteRSS |
62
|
|
|
|
|
|
|
Duadua::Parser::Bot::Feedbin |
63
|
|
|
|
|
|
|
Duadua::Parser::Bot::Inoreader |
64
|
|
|
|
|
|
|
Duadua::Parser::Bot::Fastladder |
65
|
|
|
|
|
|
|
Duadua::Parser::Bot::Feedeen |
66
|
|
|
|
|
|
|
Duadua::Parser::Bot::Feedspot |
67
|
|
|
|
|
|
|
Duadua::Parser::Bot::OldReader |
68
|
|
|
|
|
|
|
Duadua::Parser::Bot::Flipboard |
69
|
|
|
|
|
|
|
Duadua::Parser::Bot::Skype |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Duadua::Parser::Browser::Xiaomi |
72
|
|
|
|
|
|
|
Duadua::Parser::FeaturePhone::FeaturePhone |
73
|
|
|
|
|
|
|
Duadua::Parser::Bot::Netcraft |
74
|
|
|
|
|
|
|
Duadua::Parser::Bot::Barkrowler |
75
|
|
|
|
|
|
|
Duadua::Parser::Bot::SMTBot |
76
|
|
|
|
|
|
|
Duadua::Parser::Bot::AdstxtCom |
77
|
|
|
|
|
|
|
Duadua::Parser::Bot::CentroAdsCrawler |
78
|
|
|
|
|
|
|
Duadua::Parser::Bot::LetsEncrypt |
79
|
|
|
|
|
|
|
/; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
for my $parser (@PARSER_PROC_LIST) { |
82
|
|
|
|
|
|
|
eval "require $parser;"; ## no critic |
83
|
|
|
|
|
|
|
die "Could not load $parser, $@" if $@; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub new { |
87
|
418
|
|
|
418
|
1
|
1451260
|
my $class = shift; |
88
|
418
|
|
|
|
|
773
|
my $ua = shift; |
89
|
418
|
|
100
|
|
|
1482
|
my $opt = shift || {}; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
bless { |
92
|
|
|
|
|
|
|
_ua => $class->_get_ua_string($ua), |
93
|
|
|
|
|
|
|
_parsed => 0, |
94
|
|
|
|
|
|
|
_result => {}, |
95
|
|
|
|
|
|
|
_parsers => $class->_build_parsers($opt), |
96
|
|
|
|
|
|
|
_opt_version => $opt->{version}, |
97
|
418
|
|
|
|
|
1186
|
}, $class; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _build_parsers { |
101
|
418
|
|
|
418
|
|
797
|
my ($class, $opt) = @_; |
102
|
|
|
|
|
|
|
|
103
|
418
|
100
|
|
|
|
887
|
if (exists $opt->{skip}) { |
104
|
1
|
|
|
|
|
2
|
my @parsers; |
105
|
1
|
|
|
|
|
3
|
for my $p (@PARSER_PROC_LIST) { |
106
|
60
|
100
|
|
|
|
53
|
next if grep { $p eq $_ } @{$opt->{skip}}; |
|
120
|
|
|
|
|
162
|
|
|
60
|
|
|
|
|
65
|
|
107
|
58
|
|
|
|
|
77
|
push @parsers, $p; |
108
|
|
|
|
|
|
|
} |
109
|
1
|
|
|
|
|
6
|
return \@parsers; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
417
|
|
|
|
|
2263
|
return \@PARSER_PROC_LIST; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
336
|
|
|
336
|
1
|
960
|
sub opt_version { shift->{_opt_version} } |
116
|
|
|
|
|
|
|
|
117
|
411
|
|
|
411
|
1
|
979
|
sub parsers { shift->{_parsers} } |
118
|
|
|
|
|
|
|
|
119
|
30930
|
|
|
30930
|
1
|
124419
|
sub ua { shift->{_ua} } |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub reparse { |
122
|
6
|
|
|
6
|
1
|
14
|
my ($self, $ua) = @_; |
123
|
|
|
|
|
|
|
|
124
|
6
|
|
|
|
|
17
|
$self->{_ua} = $self->_get_ua_string($ua); |
125
|
6
|
|
|
|
|
16
|
$self->{_result} = {}; |
126
|
|
|
|
|
|
|
|
127
|
6
|
|
|
|
|
18
|
return $self->_parse; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub _result { |
131
|
2274
|
|
|
2274
|
|
3697
|
my ($self, $value) = @_; |
132
|
|
|
|
|
|
|
|
133
|
2274
|
100
|
|
|
|
3948
|
if ($value) { |
134
|
411
|
|
|
|
|
706
|
$self->{_result} = $value; |
135
|
411
|
|
|
|
|
696
|
return $self; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
else { |
138
|
1863
|
100
|
|
|
|
3981
|
$self->parse unless $self->{_parsed}; |
139
|
1863
|
|
|
|
|
9807
|
return $self->{_result}; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub parse { |
144
|
405
|
|
|
405
|
1
|
1855
|
my $self = shift; |
145
|
|
|
|
|
|
|
|
146
|
405
|
100
|
|
|
|
1052
|
if (ref $self eq __PACKAGE__) { |
|
|
100
|
|
|
|
|
|
147
|
401
|
|
|
|
|
812
|
$self->_parse; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
elsif ($self eq __PACKAGE__) { |
150
|
|
|
|
|
|
|
# my $d_obj = Duadua->parse('User-Agent String', $opt); |
151
|
2
|
|
|
|
|
5
|
my $d = __PACKAGE__->new(@_); |
152
|
2
|
|
|
|
|
4
|
return $d->_parse; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
else { |
155
|
|
|
|
|
|
|
# my $d_obj = Duadua::parse('User-Agent String', $opt); |
156
|
2
|
|
|
|
|
5
|
my $d = __PACKAGE__->new($self, @_); |
157
|
2
|
|
|
|
|
3
|
return $d->_parse; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub _parse { |
162
|
411
|
|
|
411
|
|
548
|
my $self = shift; |
163
|
|
|
|
|
|
|
|
164
|
411
|
|
|
|
|
1698
|
$self->_result(Duadua::Parser->parse($self)); |
165
|
411
|
|
|
|
|
616
|
$self->{_parsed} = 1; |
166
|
|
|
|
|
|
|
|
167
|
411
|
|
|
|
|
665
|
return $self; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub _get_ua_string { |
171
|
424
|
|
|
424
|
|
816
|
my ($self, $ua_raw) = @_; |
172
|
|
|
|
|
|
|
|
173
|
424
|
100
|
|
|
|
991
|
if (!defined $ua_raw) { |
174
|
5
|
100
|
66
|
|
|
31
|
return exists $ENV{HTTP_USER_AGENT} && defined $ENV{HTTP_USER_AGENT} ? $ENV{HTTP_USER_AGENT} : ''; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
419
|
100
|
|
|
|
1069
|
if (ref($ua_raw) =~ m!^HTTP::Headers!) { |
178
|
1
|
|
|
|
|
4
|
return $ua_raw->header('User-Agent'); |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
418
|
|
|
|
|
1267
|
return $ua_raw; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub name { |
185
|
242
|
|
|
242
|
1
|
718
|
shift->_result->{name}; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub is_bot { |
189
|
240
|
100
|
|
240
|
1
|
120586
|
shift->_result->{is_bot} ? 1 : 0; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub is_ios { |
193
|
240
|
100
|
|
240
|
1
|
112168
|
shift->_result->{is_ios} ? 1 : 0; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub is_android { |
197
|
240
|
100
|
|
240
|
1
|
112475
|
shift->_result->{is_android} ? 1 : 0; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub is_linux { |
201
|
240
|
100
|
|
240
|
1
|
110966
|
shift->_result->{is_linux} ? 1 : 0; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub is_windows { |
205
|
242
|
100
|
|
242
|
1
|
111618
|
shift->_result->{is_windows} ? 1 : 0; |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub is_chromeos { |
209
|
237
|
100
|
|
237
|
1
|
110662
|
shift->_result->{is_chromeos} ? 1 : 0; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub version { |
213
|
182
|
100
|
|
182
|
1
|
838
|
shift->_result->{version} || ''; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
1; |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
__END__ |