The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::Google::Search - simple OOP-ish interface to the Google SOAP API for searching

SYNOPSIS

 use Net::Google::Search;
 my $search = Net::Google::Search($service,\%args);

 $search->query(qw(aaron cope));
 map { print $_->title()."\n"; } @{$search->results()};

 # or

 foreach my $r (@{$search->response()}) {
   print "Search time :".$r->searchTime()."\n";

   # returns an array ref of Result objects
   # the same as the $search->results() method
   map { print $_->URL()."\n"; } @{$r->resultElement()}
 }

DESCRIPTION

Provides a simple OOP-ish interface to the Google SOAP API for searching.

This package is used by Net::Google.

OBJECT METHODS

$pkg = Net::Google::Search->new($service,\%args)

Where $service is a valid GoogleSearchService object.

Valid arguments are :

  • key

    String. Google API key. If none is provided then the key passed to the parent Net::Google object will be used.

  • starts_at

    Int. First result number to display. Default is 0.

  • max_results

    Int. Number of results to return. Default is 10.

  • lr

    String or array reference. Language restrictions.

  • ie

    String or array reference. Input encoding.

  • oe

    String or array reference. Output encoding.

  • safe

    Boolean.

  • filter

    Boolean.

$pkg->key($key)

Returns a string.

Returns undef if there was an error.

$pkg->query(@data)

If the first item in @data is empty, then any existing query data will be removed before the new data is added.

Returns a string of words separated by white space. Returns undef if there was an error.

$pkg->starts_at($at)

Returns an int. Default is 0.

Returns undef if there was an error.

$pkg->max_results($max)

The default set by Google is 10 results. However, if you pass a number greater than 10 the results method will make multiple calls to Google API.

Returns an int.

Returns undef if there was an error.

$pkg->restrict(@types)

If the first item in @types is empty, then any existing restrict data will be removed before the new data is added.

Returns a string. Returns undef if there was an error.

$pkg->filter($bool)

Returns true or false. Returns undef if there was an error.

$pkg->safe($bool)

Returns true or false. Returns undef if there was an error.

$pkg->lr(@lang)

Language restriction.

If the first item in @lang is empty, then any existing lr data will be removed before the new data is added.

Returns a string. Returns undef if there was an error.

$pkg->ie(@types)

Input encoding.

If the first item in @types is empty, then any existing ie data will be removed before the new data is added.

Returns a string. Returns undef if there was an error.

$pkg->oe(@types)

Output encoding.

If the first item in @types is empty, then any existing oe data will be removed before the new data is added.

Returns a string. Returns undef if there was an error.

$pkg->return_estimatedTotal($bool)

Toggle whether or not to return all the results defined by the '__estimatedTotalResultsCount' key.

Default is false.

$pkg->response()

Returns an array ref of Net::Google::Response objects, from which the search response metadata as well as the search results may be obtained.

Use this method if you would like to receive a full response as documented in the Google Web APIs Reference (the whole of section 3).

$pkg->results()

Returns an array ref of Result objects (see docs for Net::Google::Response), each of which represents one result from the search.

Use this method if you don't care about the search response metadata, and only care about the resources that are found by the search, as described in section 3.2 of the Google Web APIs Reference.

PRIVATE METHODS

$pkg->_response($first,$count)

$pkg->_state()

VERSION

0.3

DATE

Oct 26, 2002

AUTHOR

Aaron Straup Cope

CONTRIBUTORS

Marc Hedlund <marc@precipice.org>

TO DO

  • Add hooks to manage boolean searches and speacial query strings.

SEE ALSO

Net::Google

LICENSE

Copyright (c) 2002, Aaron Straup Cope. All Rights Reserved.

This is free software, you may use it and distribute it under the same terms as Perl itself.