GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  REST::GOOGLE::SEARCH (3)

.ds Aq ’

NAME

REST::Google::Search - OO interface to Google Search API

CONTENTS

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;
        }



DESCRIPTION

REST::Google::Search provides OO interface to Google REST (aka AJAX) API for searching.

METHODS

__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 WEB.

__PACKAGE__->http_referer() Get/set HTTP Referer header.

Note: Google says that you should supply a valid HTTP referer header each time you perform a request to their AJAX API, so new() raises warning unless referer is specified.

__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



Note: You can left protocol version number unspecified while making your searches since v=1.0 is passed by default.

CLASSES

REST::Google::Search contains dedicated classes for each of supported search services. You may use them instead of specifying certain service with service 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:
REST::Google::Search::Web
REST::Google::Search::Blogs
REST::Google::Search::Books
REST::Google::Search::Images
REST::Google::Search::Local
REST::Google::Search::Video
REST::Google::Search::News
REST::Google::Search::Patent

SEE ALSO

REST::Google - the base class for this module;

<http://code.google.com/apis/ajaxsearch/documentation/#fonje> - brief information about Google Search AJAX API in non-Javascript environments;

<http://code.google.com/apis/ajaxsearch/documentation/reference.html#_intro_fonje> - Google Search AJAX API documentation;

Google::Search - high-level class for Google Search AJAX API;

LICENSE AND COPYRIGHT

Copyright 2008, Eugen Sobchenko <ejs@cpan.org> and Sergey Sinkovskiy <glorybox@cpan.org>

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 REST::GOOGLE::SEARCH (3) 2016-04-04

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.