Tuesday, November 6, 2012

GET HTTP (IO::Socket)

#!/usr/bin/perl

use IO::Socket;

my $url = 'www.google.com';

my $socket = IO::Socket::INET->new(
Proto => 'tcp',
PeerAddr => $url,
PeerPort => 80) || die "|!| Can not connect...\n";

print "connecting to $url\n";
print $socket "GET $url HTTP/1.0\n\n";
$socket->recv(my $data, 1024);
print "$data \n";
close ($socket);

Credit to BufferCode

No comments:

Post a Comment