line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Alexa::API; |
2
|
1
|
|
|
1
|
|
22201
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
3
|
1
|
|
|
1
|
|
7
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
55
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
BEGIN { |
6
|
1
|
|
|
1
|
|
6
|
use Exporter (); |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
28
|
|
7
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
137
|
|
8
|
1
|
|
|
1
|
|
2
|
$VERSION = '0.07'; |
9
|
1
|
|
|
|
|
16
|
@ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
#Give a hoot don't pollute, do not export more than needed by default |
11
|
1
|
|
|
|
|
2
|
@EXPORT = qw(); |
12
|
1
|
|
|
|
|
2
|
@EXPORT_OK = qw(); |
13
|
1
|
|
|
|
|
26
|
%EXPORT_TAGS = (); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
99917
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
420030
|
|
|
1
|
|
|
|
|
30
|
|
17
|
1
|
|
|
1
|
|
662
|
use XML::Hash::LX; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
|
|
|
|
|
|
my ($class, %parameters) = @_; |
21
|
|
|
|
|
|
|
my $self; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$self->{ua} = LWP::UserAgent->new(agent => $parameters{agent} || 'Opera 10.0') or return; |
24
|
|
|
|
|
|
|
$self->{ua}->proxy('http', $parameters{proxy}) if $parameters{proxy}; |
25
|
|
|
|
|
|
|
$self->{ua}->timeout($parameters{timeout}) if $parameters{timeout}; |
26
|
|
|
|
|
|
|
$self->{ua}->default_header('X-Real-IP', $parameters{ip_address}) if $parameters{ip_address}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$self->{alexa} = (); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
bless ($self, $class); |
31
|
|
|
|
|
|
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get { |
35
|
|
|
|
|
|
|
my ($self, $domain_url) = @_; |
36
|
|
|
|
|
|
|
return unless defined $domain_url; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $res = $self->{ua}->get("http://xml.alexa.com/data?cli=10&dat=snbamz&url=$domain_url"); |
39
|
|
|
|
|
|
|
return $res->status_line if !$res->is_success; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $res_hash = XML::Hash::LX::xml2hash($res->content); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->{alexa} = \%{$res_hash->{ALEXA}} if \%{$res_hash->{ALEXA}}; |
44
|
|
|
|
|
|
|
return \%{$self->{alexa}}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#################### main pod documentation begin ################### |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
WWW::Alexa::API - A class implementation interface for querying Alexa.com for Traffic information. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 SYNOPSIS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
use WWW::Alexa::API; |
57
|
|
|
|
|
|
|
my $alexa = WWW::Alexa::API->new(); |
58
|
|
|
|
|
|
|
my $alexa_response = $alexa->get('example.com'); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DESCRIPTION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
The C is a class implementation interface for |
63
|
|
|
|
|
|
|
querying Alexa.com for Traffic information. This offers the full Alexa |
64
|
|
|
|
|
|
|
API response in a hash object. See "OUTPUT" for the structure of the response. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
To use it, you should create a C object and |
67
|
|
|
|
|
|
|
use its method to get(), to query information for a domain. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 USAGE |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $alexa = WWW::Alexa::API->new(%options); |
72
|
|
|
|
|
|
|
my $alexa_response = $alexa->get('alexa.com'); |
73
|
|
|
|
|
|
|
my $alexa_rank = $alexa_response->{SD}[1]->{POPULARITY}->{-TEXT}; |
74
|
|
|
|
|
|
|
if (defined $alexa_response->{DMOZ}) { |
75
|
|
|
|
|
|
|
## Has DMOZ |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This method constructs a new C object and returns it. |
79
|
|
|
|
|
|
|
Key/value pair arguments can be provided to set up an initial user agent. |
80
|
|
|
|
|
|
|
The following options allow specific attributes for C |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
KEY DEFAULT |
83
|
|
|
|
|
|
|
------------ -------------------- |
84
|
|
|
|
|
|
|
agent "Opera 10.0" |
85
|
|
|
|
|
|
|
proxy undef |
86
|
|
|
|
|
|
|
timeout undef |
87
|
|
|
|
|
|
|
ip_address undef |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
C specifies the header 'User-Agent' when querying Alexa. If |
91
|
|
|
|
|
|
|
the C option is passed in, requests will be made through |
92
|
|
|
|
|
|
|
specified proxy. C is the host which serve requests to Alexa. |
93
|
|
|
|
|
|
|
C allows you to set an X-Real-IP header for C. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 OUTPUT |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$VAR1 = { |
98
|
|
|
|
|
|
|
'-URL' => 'alexa.com/', |
99
|
|
|
|
|
|
|
'-VER' => '0.9', |
100
|
|
|
|
|
|
|
'-HOME' => '0', |
101
|
|
|
|
|
|
|
'-IDN' => 'alexa.com/', |
102
|
|
|
|
|
|
|
'RLS' => { |
103
|
|
|
|
|
|
|
'RL' => [ |
104
|
|
|
|
|
|
|
{ |
105
|
|
|
|
|
|
|
'-TITLE' => 'Open Directory Project', |
106
|
|
|
|
|
|
|
'-HREF' => 'dmoz.org/' |
107
|
|
|
|
|
|
|
}, { |
108
|
|
|
|
|
|
|
'-TITLE' => 'Internet Archive', |
109
|
|
|
|
|
|
|
'-HREF' => 'archive.org/' |
110
|
|
|
|
|
|
|
}, { |
111
|
|
|
|
|
|
|
'-TITLE' => 'Wiki - AboutUs Wiki Page', |
112
|
|
|
|
|
|
|
'-HREF' => 'aboutus.org/' |
113
|
|
|
|
|
|
|
}, { |
114
|
|
|
|
|
|
|
'-TITLE' => 'Ask.com', |
115
|
|
|
|
|
|
|
'-HREF' => 'www.ask.com/' |
116
|
|
|
|
|
|
|
}, { |
117
|
|
|
|
|
|
|
'-TITLE' => 'StatCounter.com', |
118
|
|
|
|
|
|
|
'HREF' => 'statcounter.com/' |
119
|
|
|
|
|
|
|
}, { |
120
|
|
|
|
|
|
|
'-TITLE' => 'Statbrain.com', |
121
|
|
|
|
|
|
|
'-HREF' => 'statbrain.com/' |
122
|
|
|
|
|
|
|
}, { |
123
|
|
|
|
|
|
|
'-TITLE' => 'SiteSell.com', |
124
|
|
|
|
|
|
|
'-HREF' => 'sitesell.com/' |
125
|
|
|
|
|
|
|
}, { |
126
|
|
|
|
|
|
|
'-TITLE' => 'Site Meter - Counter And Statistics Tracker', |
127
|
|
|
|
|
|
|
'-HREF' => 'sitemeter.com/' |
128
|
|
|
|
|
|
|
}, { |
129
|
|
|
|
|
|
|
'-TITLE' => "\x{631}\x{62a}\x{628}: \x{62a}\x{631}\x{62a}\x{64a}\x{628} \x{627}\x{644}\x{645}\x{648}\x{627}\x{642}\x{639} \x{627}\x{644}\x{639}\x{631}\x{628}\x{64a}\x{629}", |
130
|
|
|
|
|
|
|
'-HREF' => 'ratteb.com/' |
131
|
|
|
|
|
|
|
}, { |
132
|
|
|
|
|
|
|
'-TITLE' => 'Quantcast', |
133
|
|
|
|
|
|
|
'-HREF' => 'quantcast.com/' |
134
|
|
|
|
|
|
|
}, { |
135
|
|
|
|
|
|
|
'-TITLE' => 'www.amazon.com/', |
136
|
|
|
|
|
|
|
'-HREF' => 'www.amazon.com/' |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
], |
139
|
|
|
|
|
|
|
'-more' => '65', |
140
|
|
|
|
|
|
|
'-PREFIX' => 'http://' |
141
|
|
|
|
|
|
|
}, |
142
|
|
|
|
|
|
|
'-AID' => '=', |
143
|
|
|
|
|
|
|
'KEYWORDS' => { |
144
|
|
|
|
|
|
|
'KEYWORD' => [ |
145
|
|
|
|
|
|
|
{ |
146
|
|
|
|
|
|
|
'-VAL' => 'Opportunities' |
147
|
|
|
|
|
|
|
}, { |
148
|
|
|
|
|
|
|
'-VAL' => 'Partners Programs' |
149
|
|
|
|
|
|
|
}, { |
150
|
|
|
|
|
|
|
'-VAL' => 'Amazon Associates Program' |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
] |
153
|
|
|
|
|
|
|
}, |
154
|
|
|
|
|
|
|
'DMOZ' => { |
155
|
|
|
|
|
|
|
'SITE' => { |
156
|
|
|
|
|
|
|
'-DESC' => 'Alexa is the leading provider of free, global web metrics. Search Alexa to discover the most successful sites on the web by keyword, category, or country. Use our analytics for competitive analysis, benchmarking, market research, or business development. Use Alexa\'s Pro tools to optimize your company\'s presence on the web.', |
157
|
|
|
|
|
|
|
'-TITLE' => 'Alexa Internet', |
158
|
|
|
|
|
|
|
'-BASE' => 'alexa.com/', |
159
|
|
|
|
|
|
|
'CATS' => { |
160
|
|
|
|
|
|
|
'CAT' => { |
161
|
|
|
|
|
|
|
'-ID' => 'Top/Computers/Internet/Statistics_and_Demographics/Internet_Traffic', |
162
|
|
|
|
|
|
|
'-CID' => '374841', |
163
|
|
|
|
|
|
|
'-TITLE' => 'Statistics and Demographics/Internet Traffic' |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
}, |
168
|
|
|
|
|
|
|
'SD' => [ |
169
|
|
|
|
|
|
|
{ |
170
|
|
|
|
|
|
|
'COUNTRY' => { |
171
|
|
|
|
|
|
|
'-CODE' => 'US' |
172
|
|
|
|
|
|
|
}, |
173
|
|
|
|
|
|
|
'-TITLE' => 'A', |
174
|
|
|
|
|
|
|
'-FLAGS' => 'DMOZ', |
175
|
|
|
|
|
|
|
'CHILD' => { |
176
|
|
|
|
|
|
|
'-SRATING' => '0' |
177
|
|
|
|
|
|
|
}, |
178
|
|
|
|
|
|
|
'SPEED' => { |
179
|
|
|
|
|
|
|
'-TEXT' => '1611', |
180
|
|
|
|
|
|
|
'-PCT' => '52' |
181
|
|
|
|
|
|
|
}, |
182
|
|
|
|
|
|
|
'LINKSIN' => { |
183
|
|
|
|
|
|
|
'-NUM' => '358113' |
184
|
|
|
|
|
|
|
}, |
185
|
|
|
|
|
|
|
'ASSOCS' => { |
186
|
|
|
|
|
|
|
'ASSOC' => { |
187
|
|
|
|
|
|
|
'-ID' => 'alexashopping-9' |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
}, |
190
|
|
|
|
|
|
|
'CREATED' => { |
191
|
|
|
|
|
|
|
'-MONTH' => '07', |
192
|
|
|
|
|
|
|
'-DAY' => '17', |
193
|
|
|
|
|
|
|
'-YEAR' => '1996', |
194
|
|
|
|
|
|
|
'-DATE' => '17-Jul-1996' |
195
|
|
|
|
|
|
|
}, |
196
|
|
|
|
|
|
|
'CERTIFIED' => { |
197
|
|
|
|
|
|
|
'-DATE' => '2013-12-03T00:00:03Z' |
198
|
|
|
|
|
|
|
}, |
199
|
|
|
|
|
|
|
'ADDR' => { |
200
|
|
|
|
|
|
|
'-COUNTRY' => 'USA', |
201
|
|
|
|
|
|
|
'-ZIP' => '94129', |
202
|
|
|
|
|
|
|
'-STATE' => 'CA', |
203
|
|
|
|
|
|
|
'-CITY' => 'San Francisco', |
204
|
|
|
|
|
|
|
'-STREET' => 'Presidio of San Francisco, PO Box 29141' |
205
|
|
|
|
|
|
|
}, |
206
|
|
|
|
|
|
|
'LANG' => { |
207
|
|
|
|
|
|
|
'-LEX' => 'en' |
208
|
|
|
|
|
|
|
}, |
209
|
|
|
|
|
|
|
'SITEDATA' => { |
210
|
|
|
|
|
|
|
'-DISPLAY' => '7' |
211
|
|
|
|
|
|
|
}, |
212
|
|
|
|
|
|
|
'REVIEWS' => { |
213
|
|
|
|
|
|
|
'-NUM' => '939', |
214
|
|
|
|
|
|
|
'-AVG' => '4.5' |
215
|
|
|
|
|
|
|
}, |
216
|
|
|
|
|
|
|
'CLAIMED' => { |
217
|
|
|
|
|
|
|
'-DATE' => '2013-12-06T11:00:10Z' |
218
|
|
|
|
|
|
|
}, |
219
|
|
|
|
|
|
|
'TICKER' => { |
220
|
|
|
|
|
|
|
'-SYMBOL' => 'AMZN' |
221
|
|
|
|
|
|
|
}, |
222
|
|
|
|
|
|
|
'ALEXAPRO' => { |
223
|
|
|
|
|
|
|
'-TIER' => 'advanced' |
224
|
|
|
|
|
|
|
}, |
225
|
|
|
|
|
|
|
'LINK' => [ |
226
|
|
|
|
|
|
|
{ |
227
|
|
|
|
|
|
|
'-NUM' => '1', |
228
|
|
|
|
|
|
|
'-TEXT' => 'Alexa Products', |
229
|
|
|
|
|
|
|
'-URL' => 'http://www.alexa.com/products' |
230
|
|
|
|
|
|
|
}, |
231
|
|
|
|
|
|
|
{ |
232
|
|
|
|
|
|
|
'-NUM' => '2', |
233
|
|
|
|
|
|
|
'-TEXT' => 'Alexa Toolbar Creator', |
234
|
|
|
|
|
|
|
'-URL' => 'http://www.alexa.com/toolbar-creator' |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
], |
237
|
|
|
|
|
|
|
'-HOST' => 'alexa.com', |
238
|
|
|
|
|
|
|
'EMAIL' => { |
239
|
|
|
|
|
|
|
'-ADDR' => 'Alexa Internet' |
240
|
|
|
|
|
|
|
}, |
241
|
|
|
|
|
|
|
'TITLE' => { |
242
|
|
|
|
|
|
|
'-TEXT' => 'Alexa Internet' |
243
|
|
|
|
|
|
|
}, |
244
|
|
|
|
|
|
|
'LOGO' => { |
245
|
|
|
|
|
|
|
'-URL' => 'http://s3.amazonaws.com/com.alexa.data/fr_logo_url/205_4c67c060c607f3c93208e7d0f3aa00d1.png' |
246
|
|
|
|
|
|
|
}, |
247
|
|
|
|
|
|
|
'OWNER' => { |
248
|
|
|
|
|
|
|
'-NAME' => 'Alexa Internet' |
249
|
|
|
|
|
|
|
}, |
250
|
|
|
|
|
|
|
'PHONE' => { |
251
|
|
|
|
|
|
|
'-NUMBER' => 'unlisted' |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
}, |
254
|
|
|
|
|
|
|
{ |
255
|
|
|
|
|
|
|
'COUNTRY' => { |
256
|
|
|
|
|
|
|
'-RANK' => '1700', |
257
|
|
|
|
|
|
|
'-NAME' => 'United States', |
258
|
|
|
|
|
|
|
'-CODE' => 'US' |
259
|
|
|
|
|
|
|
}, |
260
|
|
|
|
|
|
|
'POPULARITY' => { |
261
|
|
|
|
|
|
|
'-TEXT' => '1502', |
262
|
|
|
|
|
|
|
'-URL' => 'alexa.com/', |
263
|
|
|
|
|
|
|
'-SOURCE' => 'certify' |
264
|
|
|
|
|
|
|
}, |
265
|
|
|
|
|
|
|
'REACH' => { |
266
|
|
|
|
|
|
|
'-RANK' => '1458' |
267
|
|
|
|
|
|
|
}, |
268
|
|
|
|
|
|
|
'RANK' => { |
269
|
|
|
|
|
|
|
'-DELTA' => '+237' |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
] |
273
|
|
|
|
|
|
|
}; |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=head1 BUGS |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
All bugs can be reported to https://github.com/rijvirajib/WWW-Alexa-API |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
Some users report issues installing XML::Hash::LX |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
C |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=head1 SUPPORT |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
Support requests can be sent to https://github.com/rijvirajib/WWW-Alexa-API |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=head1 AUTHOR |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
Rijvi Rajib |
290
|
|
|
|
|
|
|
CPAN ID: RIJ |
291
|
|
|
|
|
|
|
Cyphrd |
292
|
|
|
|
|
|
|
cpan @ rij.co |
293
|
|
|
|
|
|
|
http:/www.rij.co |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=head1 COPYRIGHT |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
This program is free software; you can redistribute |
298
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
The full text of the license can be found in the |
301
|
|
|
|
|
|
|
LICENSE file included with this module. |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=head1 SEE ALSO |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
perl(1). |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
=cut |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
#################### main pod documentation end ################### |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
1; |