vitaly has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I want to use google search in my web page created with Perl/CGI. Your help will be very much appreciated.
  • Comment on How to call google search in Perl/CGI script

Replies are listed 'Best First'.
Re: How to call google search in Perl/CGI script
by moritz (Cardinal) on Jan 13, 2008 at 22:23 UTC
    There used to be an api, but iirc Google doesn't give out new API keys, and doesn't like being spidered.

    So the short answer is: you shouldn't.

    Technically it should still be possible with modules like WWW::Mechanize and Web::Scraper.

    Of course you can search on cpan for google and see if any of those modules work for you.

Re: How to call google search in Perl/CGI script
by Joost (Canon) on Jan 14, 2008 at 00:53 UTC
      Google Custom Search might be the solution. Free (with ads), customizable, Google search from your own pages. The business edition, as Joost says, is $100 per year and has no ads.
Re: How to call google search in Perl/CGI script
by dsheroh (Monsignor) on Jan 14, 2008 at 17:38 UTC
    If you're just looking to embed a standard google search in the page (i.e., user types in search terms and they get displayed on a result page), I believe the Google AJAX Search API should provide what you need.

    If, OTOH, you want to programmatically submit a search behind the scenes and do processing of the returned results before (or instead of) displaying them on a web page for the user, then, so far as I've been able to determine, the only option for doing so at this time is to violate google's terms of service.

Re: How to call google search in Perl/CGI script
by Karpio (Initiate) on Jan 15, 2008 at 15:13 UTC
    !/usr/bin/perl -w use SOAP::Lite; my $query = "perl"; my $googleSearch = SOAP::Lite -> service("http://api.google.com/Google +Search.wsdl"); my $result = $googleSearch -> doGoogleSearch( "iwnUXUtHj3bteg5FWfBJDwui3SPeB+iy", # password to access googl +e $query, 0, # Fisrt result 10, # Number of results "false", # Filter '', # Restriction "false", # Secure Search '', # lr 'latin1', # ie 'latin1' # oe ); print $result->{resultElements}->[0]->{title}; print "\n"; print $result->{resultElements}->[0]->{URL}; print "\n"; 1;