[gull] requête http avec perl

Francois Deppierraz francois at ctrlaltdel.ch
Wed Jun 8 19:00:04 CEST 2005


On Wed, Jun 08, 2005 at 06:43:51PM +0200, marquis at altern.org wrote:

Hello,

> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> use IO::Socket;
> 
> my $sock = new IO::Socket::INET(
> 	PeerAddr => 'www.edicom.ch',
> 	PeerPort=>80,
> 	Proto => "tcp");
> die "Could not create socket\n" unless $sock;
> my $req = "GET / HTTP/1.1\r\n
> Connection: Keep-Alive\r\n
> Pragma: no-cache\r\n
> Cache-control: no-cache\r\n
> Accept: text/*, image/jpeg, image/png, image/*, */*\r\n
> Accept-Encoding: x-gzip, x-deflate, gzip, deflate, identity\r\n
> Accept-Charset: iso-8859-1, utf-8;q=0.5, *;q=0.5\r\n
> Accept-Language: en, US\r\n
> Host: www.edicom.ch\r\n
> Cookie: CP=null*; CFID=971123;OKEN=67014803\r\n\r\n";
> 
> 
> print $sock $req;
> 
> print <$sock>;
> 
> close ($sock);

Il est nettement plus simple d'utiliser LWP (package libwww-perl sous
Debian) pour ce genre d'application. Un exemple est disponible avec
"perldoc LWP".



More information about the gull mailing list