Powered by coANDco UK

Howto download a Webpage

From How2s

This How2 describes how to connect to a server and how to communicate with it. There is an example script that downloads on port 80 a html page from a server via HTTP.

use Socket;
use Getopt::Std;


socket(SOCK,PF_INET,SOCK_STREAM,getprotobyname('tcp')) or die "socket(): $!\n";
$paddr = sockaddr_in(80,inet_aton($SERVER));
connect (SOCK,$paddr) || die "connect(): $!\n";
select (SOCK); $| = 1; select STDOUT;
print SOCK "GET $PATH HTTP/1.0\n\n";
Please check out our sponsor, thanks to whom How2s.org is FREE: