Perl google client

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;

0 comments

  1. GaSPaRD

    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

  2. GaSPaRD

    Salut, j'aurais aimé savoir ce que tu mettais dans ton Psybnc pour lancer le script perl et renvoyer le resultat sur irc. Merci :)

  3. GaSPaRD

    Salut, j'aurais aimé savoir ce que tu mettais dans ton Psybnc pour lancer le script perl et renvoyer le resultat sur irc. Merci :)

  4. GaSPaRD

    Désolé pour la répetition :)

  5. Ozh

    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