This script queries Google and returns the first result (the one you'd get hitting the "I Feel Lucky" button). I did it because I wanted not to use LWP::Simple on a computer where the lib was missing. Consider this as is my minimalistic web client example.
(the fancy stuff that might confuse you, as "print NOTICE", are for a PsyBNC integration. Ignore them)
-
#!/usr/bin/perl
-
-
use IO::Socket;
-
$nick = shift (@ARGV);
-
-
if ($#ARGV <0 ) {
-
print ":g00gle NOTICE $nick :Err…. google what ffs m8 ?\n" ;
-
exit;
-
}
-
-
$host = "www.google.com";
-
$document = "/search?btnI=\&q=" . join ("+", @ARGV);
-
$kikoo=0;
-
-
$EOL = "\015\012";
-
$BLANK = $EOL x 2;
-
-
$remote = IO::Socket::INET->new(
-
Proto => "tcp",
-
PeerAddr => $host,
-
PeerPort => "http(80)",
-
);
-
-
unless ($remote) { die "cannot connect to http daemon on $host"; }
-
$remote->autoflush(1);
-
print $remote "GET $document HTTP/1.0" . $BLANK;
-
while ( <$remote> ) {
-
if (m/^location/i ) {
-
$tutu = $_ ;
-
$tutu=~s/^location: //i;
-
print ":g00gle NOTICE $nick :$tutu"; $kikoo = 1;
-
} ;
-
}
-
close $remote;
-
-
print ":g00gle NOTICE $nick :No result ffs m8 !\n" unless $kikoo;
wrote, on 15/Aug/04 at 11:09 pm # :
Salut, j'aurais aimé savoir ce que tu mettais dans ton Psybnc pour lancer le script perl et renvoyer le resultat sur irc. Merci :)
commented, on 15/Aug/04 at 11:39 pm # :
Salut, j'aurais aimé savoir ce que tu mettais dans ton Psybnc pour lancer le script perl et renvoyer le resultat sur irc. Merci :)
said, on 15/Aug/04 at 11:40 pm # :
Désolé pour la répetition :)
thought, on 18/Aug/04 at 3:57 pm # :
ca depend si tu veux que le script soit accessible à un user ou a tout le monde
http://www.psybnc.info/ y'a des exemples des 2 cas
commented, on 08/Oct/04 at 6:39 pm # :
C'est bon j'ai reussi, et j'ai fait mon propre script pour google :)
Voici le lien si ça peux interesser quelqu'un :
http://scripts.hollywoud.net/perl-psybnc/google.pl.txt