Requesting web pages

Hello,

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.

Thanks,

Joe
jvieiraAsked:
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.

prakashk021799Commented:
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 <http://www.activestate.com/packages/zips/libwww-perl.zip> 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.
0
jvieiraAuthor Commented:
I downloaded the libwww-perl.zip and installed it.  When I type perldoc get, I just get a carriage return.  How do I use the GET command?

Thanks,

Joe
0
jhurstCommented:
Here is what I use:

#!/usr/local/bin/perl
use IO::Socket;
$EOL = "\015\012";
$BLANK = $EOL x 2;
print "Host: ";
$host=<STDIN>;
$host=~ s/\n//;
print "Document: ";
$document=<STDIN>;
$document=~ s/\n//;

open(OUT,">/tmp/resource.tmp");
{$document="\/" . $document;}

    $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" . $EOL;
    print $remote "REFERER: www.JohnWilliie.com/" . $EOL;
    print $remote "host: $host" . $BLANK;
    while ( <$remote> ) {
    if (length($_) <5) {$inBody++}
    if ($inBody) {print OUT }
    else {print }
    }

    close $remote;
0

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: www.JohnWilliie.com/" . $EOL;

Joe


0
jvieiraAuthor Commented:
What's this line for:
print $remote "REFERER: www.JohnWilliie.com/" . $EOL;

Joe
0
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
Perl

From novice to tech pro — start learning today.