Requesting web pages


I'm using perl for Win32 on NT workstation.  Can someone tell me how to write a perl script to request web pages (html, htm, asp, cgi, etc...)  Provided I give the web site and page name.  I know it has some thing to do with the GET command but I lost my perl book and need this fast.  Sample script would be appreciated.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If your perl came with the libwww-perl bundle, then you already have a script called (appropriately) GET, which you can use to get web pages.

Try the following command (in a DOS window) to find out if you have it:

perldoc GET

If you have the script, then you should get the documentation for this script displayed.

If you don't have it, get the file <> and install it.

If your perl distribution is from ActiveState, there is an easier method to install the bundle. Just use the 'ppm.bat' script that is part of the ActivePerl distribution.
jvieiraAuthor Commented:
I downloaded the and installed it.  When I type perldoc get, I just get a carriage return.  How do I use the GET command?


Here is what I use:

use IO::Socket;
$EOL = "\015\012";
$BLANK = $EOL x 2;
print "Host: ";
$host=~ s/\n//;
print "Document: ";
$document=~ s/\n//;

{$document="\/" . $document;}

    $remote = IO::Socket::INET->new( Proto     => "tcp",
                                     PeerAddr  => $host,
                                     PeerPort  => "http(80)",
    unless ($remote) { die "cannot connect to http daemon on $host" }
    print $remote "GET $document HTTP/1.0" . $EOL;
    print $remote "REFERER:" . $EOL;
    print $remote "host: $host" . $BLANK;
    while ( <$remote> ) {
    if (length($_) <5) {$inBody++}
    if ($inBody) {print OUT }
    else {print }

    close $remote;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jvieiraAuthor Commented:
What's this line for:
print $remote "REFERER:" . $EOL;


jvieiraAuthor Commented:
What's this line for:
print $remote "REFERER:" . $EOL;

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.