=head1 NAME REST::Google::Search - OO interface to Google Search API =head1 SYNOPSIS use REST::Google::Search; REST::Google::Search->http_referer('http://example.com'); my $res = REST::Google::Search->new( q => 'Larry Wall', ); die "response status failure" if $res->responseStatus != 200; my $data = $res->responseData; my $cursor = $data->cursor; my $pages = $cursor->pages; printf "current page index: %s\n", $cursor->currentPageIndex; printf "estimated result count: %s\n", $cursor->estimatedResultCount; my @results = $data->results; foreach my $r (@results) { printf "\n"; printf "title: %s\n", $r->title; printf "url: %s\n", $r->url; } =head1 DESCRIPTION C provides OO interface to Google REST (aka AJAX) API for searching. =head1 METHODS =over =item __PACKAGE__->service() Get/set service to use. The following table lists the URL used to access Google search services: service address ------- ------------------------------------------------------ WEB http://ajax.googleapis.com/ajax/services/search/web VIDEO http://ajax.googleapis.com/ajax/services/search/video NEWS http://ajax.googleapis.com/ajax/services/search/news LOCAL http://ajax.googleapis.com/ajax/services/search/local IMAGES http://ajax.googleapis.com/ajax/services/search/images BOOKS http://ajax.googleapis.com/ajax/services/search/books BLOGS http://ajax.googleapis.com/ajax/services/search/blogs PATENT http://ajax.googleapis.com/ajax/services/search/patent Service constants are exported on demand, so you can use the constants instead of service URLs: use REST::Google::Search qw/VIDEO/; REST::Google::Search->service( VIDEO ); Default service is C. =item __PACKAGE__->http_referer() Get/set HTTP C header. I Google says that you should supply a valid HTTP referer header each time you perform a request to their AJAX API, so C raises warning unless referer is specified. =item __PACKAGE__->new() The constructor use it's arguments to build a valid HTTP GET request to Google Search service, so it takes the same arguments as the web service takes. Please refer to 'Google Search AJAX API' documentation for complete list of arguments for Google Search. E.g.: my $res = REST::Google::Search->new( q => 'Pamela Anderson', start => 4, hl => 'fr' ); If you're using the default (WEB) search, the code above will perform a following HTTP GET request: http://ajax.googleapis.com/ajax/services/search/web?hl=fr&q=Pamela+Anderson&v=1.0&start=4 I You can left protocol version number unspecified while making your searches since C is passed by default. =back =head1 CLASSES C contains dedicated classes for each of supported search services. You may use them instead of specifying certain service with C class method. E.g: use REST::Google::Search::Blogs; # ... # set referer, etc my $r = REST::Google::Search::Blogs->new( q => 'foobar' ); is the same as: use REST::Google::Search qw/BLOGS/; REST::Google::Search->service( BLOGS ); # ... # set referer, etc my $r = REST::Google::Search->new( q => 'foobar' ); Available classes: =over =item L =item L =item L =item L =item L =item L =item L =item L =back =head1 SEE ALSO L - the base class for this module; L - brief information about Google Search AJAX API in non-Javascript environments; L - Google Search AJAX API documentation; L - high-level class for Google Search AJAX API; =head1 LICENSE AND COPYRIGHT Copyright 2008, Eugen Sobchenko and Sergey Sinkovskiy This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.