2011-12-11 19:29:55 +01:00
|
|
|
#!/usr/bin/perl
|
2011-12-06 17:46:39 +01:00
|
|
|
|
|
|
|
# Quick and dirty by :pragma
|
|
|
|
|
2011-12-11 19:29:55 +01:00
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
2011-12-06 17:46:39 +01:00
|
|
|
use Google::Search;
|
2012-01-05 12:04:55 +01:00
|
|
|
use HTML::Entities;
|
2011-12-06 17:46:39 +01:00
|
|
|
|
|
|
|
my ($nick, $arguments, $matches);
|
|
|
|
|
|
|
|
$matches = 3;
|
|
|
|
$nick = shift @ARGV;
|
|
|
|
|
|
|
|
if ($#ARGV < 0)
|
|
|
|
{
|
|
|
|
print "Usage: google [number of results] query\n";
|
|
|
|
die;
|
|
|
|
}
|
|
|
|
|
|
|
|
$arguments = join(" ", @ARGV);
|
|
|
|
|
|
|
|
if($arguments =~ m/^([0-9]+)/)
|
|
|
|
{
|
|
|
|
$matches = $1;
|
|
|
|
$arguments =~ s/^$1//;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $search = Google::Search->Web(query => $arguments, referrer => 'http://blackshell.com');
|
|
|
|
|
|
|
|
print "$nick: ";
|
|
|
|
|
|
|
|
if(not $search->first) {
|
|
|
|
print $search->error->reason, "\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $comma = "";
|
|
|
|
while( my $result = $search->next) {
|
2012-01-05 12:04:55 +01:00
|
|
|
print $comma, decode_entities $result->titleNoFormatting, ": ", $result->uri;
|
2011-12-06 17:46:39 +01:00
|
|
|
$comma = " -- ";
|
|
|
|
last if --$matches <= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
print "\n";
|