#!/usr/local/bin/perl ## get_web_test.pl ########################################################### # Gets any web page's source and sends the HTML to the # browser, the output could have been stored in a file # at your site, or directed to further code that # parses the output and makes a web page based on the # information downloaded. This is the start of some # really cool scripts, the possibilities are endless! # # For more examples and free sources, visit www.nocrash.com ########################################################### use IO::Socket; #print "Content-Type: text/html\n\n"; print "\n-BEGIN-\n"; $host = "www.nasa.gov"; ## in this example we get 'www.nasa.gov/index.html' $document = "/index.html"; $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; ## we don't have to print here, you now have the page's source, do with it what you want! while ( <$remote> ) { print } close $remote; print "\n-END-\n";