404使用Net :: Google时出错

时间:2012-05-02 07:02:32

标签: perl google-api irc

我只是为我和我的朋友写一个简单的机器人在IRC上使用。 找到这个模块,但由于某种原因,即使我按照这些例子,我也无法实际搜索 可以看到模块here.
我可以看到我的代码基于示例here.

据我所知,我没有犯任何错误。

当我打开调试时,我收到此输出(仅在调试开启的最后一行);

<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

我的代码;

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

任何想法都是我收到错误消息的原因?
我有use Net::Google;use SOAP::Lite;我已经检查了SOAP目录,Lite.pm肯定在那里...谷歌一直没有帮助,所以我有点亏。

1 个答案:

答案 0 :(得分:0)

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