Search code examples
perlgoogle-apiirc

404 Error using Net::Google


I'm just writing a simple bot for me and my friends to use on IRC. Found this module, but for some reason, even though I've followed the examples, I can't get it to actually search.
Module can be seen here.
Example my code is based off can be seen here.

As far as I can tell, I'm not making any mistakes.

I receive this output when I turn debugging on (only get the last line with debugging on);

<p><b>404.</b> <ins>Thatâs an error.</ins>
<p>The requested URL <code>/search/beta2</code> was not found on this server.
<ins>Thatâs all we know.</ins>
404 Not Found at /usr/lib/perl5/vendor_perl/5.8.8/SOAP/Lite.pm line 3720

My code;

$msg =~ s/^google//g; # Get query
my $google = Net::Google->new(key => GOOGLE_API_KEY, debug => 1); # Create search instance
my $search = $google->search(); # Build query
$search->query($msg);
$search->starts_at(0);
$search->max_results(100);
$search->filter(0);

$search->results(); # Search google
my $random = int(rand(100));
my $count = 0;

foreach my $result ( @{$search->results()})
{
    if ($count == $random)
    {
        $irc->yield(privmsg => CHANNEL, $result->title() || "No Title");
        $irc->yield(privmsg => CHANNEL, $result->URL());
    }
    $count++;
}

Any idea's why I'm getting the error message?
I've got use Net::Google; and use SOAP::Lite; and I've checked the SOAP directory, Lite.pm is definitely there...google has been no help, so I'm at a bit of a loss.


Solution

  • use Google::Search;
    my $search = Google::Search->Web( query => "rock" );
    while ( my $result = $search->next ) 
    {
        print $result->rank, " ", $result->uri, " ",$result->title."\n";
    }