• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

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
0
jvieira
Asked:
jvieira
  • 3
1 Solution
 
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
 
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

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now