line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Google::CustomSearch::Result; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$WWW::Google::CustomSearch::Result::VERSION = '0.37'; |
4
|
|
|
|
|
|
|
$WWW::Google::CustomSearch::Result::AUTHORITY = 'cpan:MANWAR'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
WWW::Google::CustomSearch::Result - Placeholder for Google JSON/Atom Custom Search Result. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.37 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
5
|
|
|
5
|
|
71
|
use 5.006; |
|
5
|
|
|
|
|
12
|
|
17
|
5
|
|
|
5
|
|
20
|
use Data::Dumper; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
180
|
|
18
|
5
|
|
|
5
|
|
1875
|
use WWW::Google::CustomSearch::Item; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
142
|
|
19
|
5
|
|
|
5
|
|
1868
|
use WWW::Google::CustomSearch::Page; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
132
|
|
20
|
5
|
|
|
5
|
|
1878
|
use WWW::Google::CustomSearch::Request; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
127
|
|
21
|
|
|
|
|
|
|
|
22
|
5
|
|
|
5
|
|
28
|
use Moo; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
15
|
|
23
|
5
|
|
|
5
|
|
1304
|
use namespace::autoclean; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
18
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has [qw(api_key raw)] => (is => 'ro', required => 1); |
26
|
|
|
|
|
|
|
has [qw(kind formattedTotalResults formattedSearchTime totalResults searchTime url_template url_type request nextPage previousPage items)] => (is => 'ro'); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub BUILD { |
29
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $raw = $self->raw; |
32
|
0
|
|
|
|
|
|
$self->{'kind'} = $raw->{'kind'}; |
33
|
0
|
|
|
|
|
|
$self->{'formattedTotalResults'} = $raw->{'searchInformation'}->{'formattedTotalResults'}; |
34
|
0
|
|
|
|
|
|
$self->{'formattedSearchTime'} = $raw->{'searchInformation'}->{'formattedSearchTime'}; |
35
|
0
|
|
|
|
|
|
$self->{'totalResults'} = $raw->{'searchInformation'}->{'totalResults'}; |
36
|
0
|
|
|
|
|
|
$self->{'searchTime'} = $raw->{'searchInformation'}->{'searchTime'}; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$self->{'url_template'} = $raw->{'url'}->{'template'}; |
39
|
0
|
|
|
|
|
|
$self->{'url_type'} = $raw->{'url'}->{'type'}; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$raw->{'queries'}->{'request'}->[0]->{'api_key'} = $self->api_key; |
42
|
0
|
|
|
|
|
|
$self->{'request'} = WWW::Google::CustomSearch::Request->new($raw->{'queries'}->{'request'}->[0]); |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
0
|
|
|
|
if (defined $raw->{'queries'}->{'nextPage'} && (scalar(@{$raw->{'queries'}->{'nextPage'}}))) { |
|
0
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$raw->{'queries'}->{'nextPage'}->[0]->{'api_key'} = $self->api_key; |
46
|
0
|
|
|
|
|
|
$self->{'nextPage'} = WWW::Google::CustomSearch::Page->new($raw->{'queries'}->{'nextPage'}->[0]); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
0
|
|
|
|
if (defined $raw->{'queries'}->{'previousPage'} && (scalar(@{$raw->{'queries'}->{'previousPage'}}))) { |
|
0
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$raw->{'queries'}->{'previousPage'}->[0]->{'api_key'} = $self->api_key; |
51
|
0
|
|
|
|
|
|
$self->{'previousPage'} = WWW::Google::CustomSearch::Page->new($raw->{'queries'}->{'previousPage'}->[0]); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
foreach (@{$raw->{items}}) { |
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
push @{$self->{items}}, WWW::Google::CustomSearch::Item->new($_); |
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 DESCRIPTION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Provides the interface to the individual search results based on the search criteria. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 METHODS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 kind() |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Returns the 'kind' attribute of the search result. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
use strict; use warnings; |
70
|
|
|
|
|
|
|
use WWW::Google::CustomSearch; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
73
|
|
|
|
|
|
|
my $cx = 'Search_Engine_Identifier'; |
74
|
|
|
|
|
|
|
my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx); |
75
|
|
|
|
|
|
|
my $result = $engine->search("Google"); |
76
|
|
|
|
|
|
|
print "Kind: ", $result->kind, "\n"; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 formattedTotalResults() |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns the 'formattedTotalResults' attribute of the search result. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
use strict; use warnings; |
83
|
|
|
|
|
|
|
use WWW::Google::CustomSearch; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
86
|
|
|
|
|
|
|
my $cx = 'Search_Engine_Identifier'; |
87
|
|
|
|
|
|
|
my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx); |
88
|
|
|
|
|
|
|
my $result = $engine->search("Google"); |
89
|
|
|
|
|
|
|
print "Formatted Total Results: ", $result->formattedTotalResults, "\n"; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 formattedSearchTime() |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Returns the 'formattedSearchTime' attribute of the search result. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
use strict; use warnings; |
96
|
|
|
|
|
|
|
use WWW::Google::CustomSearch; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
99
|
|
|
|
|
|
|
my $cx = 'Search_Engine_Identifier'; |
100
|
|
|
|
|
|
|
my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx); |
101
|
|
|
|
|
|
|
my $result = $engine->search("Google"); |
102
|
|
|
|
|
|
|
print "Formatted Search Time: ", $result->formattedSearchTime, "\n"; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 totalResults() |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns the 'totalResults' attribute of the search result. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
use strict; use warnings; |
109
|
|
|
|
|
|
|
use WWW::Google::CustomSearch; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
112
|
|
|
|
|
|
|
my $cx = 'Search_Engine_Identifier'; |
113
|
|
|
|
|
|
|
my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx); |
114
|
|
|
|
|
|
|
my $result = $engine->search("Google"); |
115
|
|
|
|
|
|
|
print "Total Results: ", $result->totalResults, "\n"; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 searchTime() |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Returns the 'searchTime' attribute of the search result. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
use strict; use warnings; |
122
|
|
|
|
|
|
|
use WWW::Google::CustomSearch; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
125
|
|
|
|
|
|
|
my $cx = 'Search_Engine_Identifier'; |
126
|
|
|
|
|
|
|
my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx); |
127
|
|
|
|
|
|
|
my $result = $engine->search("Google"); |
128
|
|
|
|
|
|
|
print "Search Time: ", $result->searchTime, "\n"; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 url_template() |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Returns the URL template attribute of the search result. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
use strict; use warnings; |
135
|
|
|
|
|
|
|
use WWW::Google::CustomSearch; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
138
|
|
|
|
|
|
|
my $cx = 'Search_Engine_Identifier'; |
139
|
|
|
|
|
|
|
my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx); |
140
|
|
|
|
|
|
|
my $result = $engine->search("Google"); |
141
|
|
|
|
|
|
|
print "URL Template: ", $result->url_template, "\n"; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 url_type() |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Returns the URL Type attribute of the search result. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
use strict; use warnings; |
148
|
|
|
|
|
|
|
use WWW::Google::CustomSearch; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
151
|
|
|
|
|
|
|
my $cx = 'Search_Engine_Identifier'; |
152
|
|
|
|
|
|
|
my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx); |
153
|
|
|
|
|
|
|
my $result = $engine->search("Google"); |
154
|
|
|
|
|
|
|
print "URL Type: ", $result->url_type, "\n"; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 request() |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Returns the request L object used in the last |
159
|
|
|
|
|
|
|
search. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
use strict; use warnings; |
162
|
|
|
|
|
|
|
use WWW::Google::CustomSearch; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
165
|
|
|
|
|
|
|
my $cx = 'Search_Engine_Identifier'; |
166
|
|
|
|
|
|
|
my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx); |
167
|
|
|
|
|
|
|
my $result = $engine->search("Google"); |
168
|
|
|
|
|
|
|
my $request = $result->request; |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 nextPage() |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Returns the next page L object which can be used |
173
|
|
|
|
|
|
|
to fetch the next page result. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
use strict; use warnings; |
176
|
|
|
|
|
|
|
use WWW::Google::CustomSearch; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
179
|
|
|
|
|
|
|
my $cx = 'Search_Engine_Identifier'; |
180
|
|
|
|
|
|
|
my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx); |
181
|
|
|
|
|
|
|
my $result = $engine->search("Google"); |
182
|
|
|
|
|
|
|
my $page = $result->nextPage; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head2 previousPage() |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Returns the previous page L object which can be |
187
|
|
|
|
|
|
|
used to fetch the previous page result. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
use strict; use warnings; |
190
|
|
|
|
|
|
|
use WWW::Google::CustomSearch; |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
193
|
|
|
|
|
|
|
my $cx = 'Search_Engine_Identifier'; |
194
|
|
|
|
|
|
|
my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx, start => 2); |
195
|
|
|
|
|
|
|
my $result = $engine->search("Google"); |
196
|
|
|
|
|
|
|
my $page = $result->previousPage; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 items() |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Returns list of search item L based on the search |
201
|
|
|
|
|
|
|
criteria. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
use strict; use warnings; |
204
|
|
|
|
|
|
|
use WWW::Google::CustomSearch; |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
my $api_key = 'Your_API_Key'; |
207
|
|
|
|
|
|
|
my $cx = 'Search_Engine_Identifier'; |
208
|
|
|
|
|
|
|
my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx); |
209
|
|
|
|
|
|
|
my $result = $engine->search("Google"); |
210
|
|
|
|
|
|
|
my $items = $result->items; |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 AUTHOR |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Mohammad S Anwar, C<< >> |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 REPOSITORY |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
L |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
David Kitcher-Jones (m4ddav3) |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 BUGS |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Please report any bugs or feature requests to C
|
227
|
|
|
|
|
|
|
rt.cpan.org>, or through the web interface at L. |
228
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your |
229
|
|
|
|
|
|
|
bug as I make changes. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 SUPPORT |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
perldoc WWW::Google::CustomSearch::Result |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
You can also look for information at: |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=over 4 |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
L |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
L |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=item * CPAN Ratings |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
L |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=item * Search CPAN |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
L |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=back |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
Copyright (C) 2011 - 2015 Mohammad S Anwar. |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
This program is free software; you can redistribute it and / or modify it under |
264
|
|
|
|
|
|
|
the terms of the the Artistic License (2.0). You may obtain a copy of the full |
265
|
|
|
|
|
|
|
license at: |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
L |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified Versions is |
270
|
|
|
|
|
|
|
governed by this Artistic License.By using, modifying or distributing the Package, |
271
|
|
|
|
|
|
|
you accept this license. Do not use, modify, or distribute the Package, if you do |
272
|
|
|
|
|
|
|
not accept this license. |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made by someone |
275
|
|
|
|
|
|
|
other than you,you are nevertheless required to ensure that your Modified Version |
276
|
|
|
|
|
|
|
complies with the requirements of this license. |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service mark, |
279
|
|
|
|
|
|
|
tradename, or logo of the Copyright Holder. |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge patent license |
282
|
|
|
|
|
|
|
to make, have made, use, offer to sell, sell, import and otherwise transfer the |
283
|
|
|
|
|
|
|
Package with respect to any patent claims licensable by the Copyright Holder that |
284
|
|
|
|
|
|
|
are necessarily infringed by the Package. If you institute patent litigation |
285
|
|
|
|
|
|
|
(including a cross-claim or counterclaim) against any party alleging that the |
286
|
|
|
|
|
|
|
Package constitutes direct or contributory patent infringement,then this Artistic |
287
|
|
|
|
|
|
|
License to you shall terminate on the date that such litigation is filed. |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND |
290
|
|
|
|
|
|
|
CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED |
291
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR |
292
|
|
|
|
|
|
|
NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS |
293
|
|
|
|
|
|
|
REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, |
294
|
|
|
|
|
|
|
INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE |
295
|
|
|
|
|
|
|
OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=cut |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
1; # End of WWW::Google::CustomSearch::Result |