line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::Google::Cache - simple OOP-ish interface to the Google SOAP API for |
6
|
|
|
|
|
|
|
cached documents |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Net::Google::Cache; |
11
|
|
|
|
|
|
|
my $cache = Net::Google::Cache(\%args); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$cache->url("http://aaronland.net); |
14
|
|
|
|
|
|
|
print $cache->get(); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Provides a simple OOP-ish interface to the Google SOAP API for cached |
19
|
|
|
|
|
|
|
documents. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This package is used by I. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
26
|
|
|
|
|
|
|
package Net::Google::Cache; |
27
|
1
|
|
|
1
|
|
5
|
use base qw (Net::Google::tool); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
85
|
|
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
367
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$Net::Google::Cache::VERSION = '1.0'; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 PACKAGE METHODS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 __PACKAGE__->new(\%args) |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Valid arguments are : |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=over 4 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item * |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
B |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
I. A Google API key. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
If none is provided then the key passed to the parent I |
50
|
|
|
|
|
|
|
object will be used. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item * |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
B |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
I. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
B |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
I. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Get/set the URL for proxy-ing HTTP request. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Returns a string. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item * |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
B |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Valid options are: |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=over 4 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item * |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
I |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
If true prints debugging information returned by SOAP::Lite |
81
|
|
|
|
|
|
|
to STDERR |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
I. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Your own subroutine for munging the debugging information |
88
|
|
|
|
|
|
|
returned by SOAP::Lite. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=back |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
The object constructor in Net::Google 0.53, and earlier, expected |
95
|
|
|
|
|
|
|
a I object as its first argument followed by |
96
|
|
|
|
|
|
|
a hash reference of argument. Versions 0.6 and higher are backwards |
97
|
|
|
|
|
|
|
compatible. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Returns an object. Woot! |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub new { |
104
|
1
|
|
|
1
|
1
|
2
|
my $pkg = shift; |
105
|
|
|
|
|
|
|
|
106
|
1
|
|
|
|
|
2
|
my $self = {}; |
107
|
1
|
|
|
|
|
4
|
bless $self,$pkg; |
108
|
|
|
|
|
|
|
|
109
|
1
|
0
|
|
|
|
19
|
if (! $self->init(@_)) { |
110
|
0
|
|
|
|
|
0
|
return undef; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
0
|
return $self; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub init { |
117
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
118
|
|
|
|
|
|
|
|
119
|
1
|
|
0
|
|
|
9
|
my $args = $self->SUPER::init("cache",@_) |
120
|
|
|
|
|
|
|
|| return 0; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# |
123
|
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
|
if ($args->{'url'}) { |
125
|
0
|
|
|
|
|
|
$self->url($args->{'url'}); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
return 1; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 $obj->key($string) |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Get/set the Google API key for this object. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# Defined in Net::Google::tool |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 $obj->http_proxy($url) |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Get/set the HTTP proxy for this object. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Returns a string. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# Defined in Net::Google::tool |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 $pkg->url($url) |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Set the cached URL to fetch from the Google servers. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Returns a string. Returns an undef if there was an error. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub url { |
162
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
163
|
0
|
|
|
|
|
|
my $url = shift; |
164
|
|
|
|
|
|
|
|
165
|
0
|
0
|
|
|
|
|
if (defined($url)) { |
166
|
0
|
|
|
|
|
|
$self->{'_url'} = $url; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
return $self->{'_url'}; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 $pkg->get() |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Fetch the requested URL from the Google servers. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Returns a string. Returns undef if there was an error. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub get { |
181
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
182
|
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
$self->_queries(1); |
184
|
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
return $self->{'_service'}->doGetCachedPage( |
186
|
|
|
|
|
|
|
$self->key(), |
187
|
|
|
|
|
|
|
$self->url(), |
188
|
|
|
|
|
|
|
); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 $obj->queries_exhausted() |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Returns true or false depending on whether or not the current in-memory |
194
|
|
|
|
|
|
|
B has exhausted the Google API 1000 query limit. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# Defined in Net::Google::tool |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 VERSION |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
1.0 |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 DATE |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
$Date: 2005/03/26 20:49:03 $ |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 AUTHOR |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Aaron Straup Cope |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 TO DO |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=over 4 |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=item * |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Add hooks to I method to strip out Google headers and footers from cached pages. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=back |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 SEE ALSO |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
L |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head1 LICENSE |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
Copyright (c) 2002-2005, Aaron Straup Cope. All Rights Reserved. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
This is free software, you may use it and distribute it under the same terms as Perl itself. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=cut |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
return 1; |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
} |