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