Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm looking for something along the line of
$web_page = http_get "cpan.org/modules/00modlist.long.html";
Does anything like this exist?

Replies are listed 'Best First'.
Re: HTTP client in perl
by perlmonkey (Hermit) on Apr 26, 2000 at 11:49 UTC
    There is a package like that: LWP::Simple
    Here is a sample program:
    #!/usr/bin/perl use LWP::Simple; $content = get("http://www.perl.org") ; print $content;
    There is a lot of neat stuff with LPW::Simple and LWP::UserAgent.
    Check them out. Also there is other related notes here
Re: HTTP client in perl
by dlc (Acolyte) on Apr 26, 2000 at 15:23 UTC

    If you have libwww-perl (LWP) installed, try perldoc lwpcook. You can also grab the file from the LWP site.

    darren

Re: HTTP client in perl
by lostcause (Monk) on Apr 26, 2000 at 23:11 UTC

    From the lwpcook doc http://www.linpro.no/lwp/libwww-perl/lwpcook.pod comes this generic http client - in my time of need this did it for me:

    #!/usr/local/bin/perl -w
    use LWP::UserAgent;
    $myurl = "http://www.perlmonks.org";
    $ua = new LWP::UserAgent; $ua->agent("$0/0.1 " . $ua->agent);
    $ua->agent("Mozilla/8.0");
    # pretend we are very capable browser
    $req = new HTTP::Request 'GET' => "$myurl";
    $req->header('Accept' => 'text/html');
    # send request $res = $ua->request($req);
    # check the outcome if ($res->is_success) {
    print $res->content;
    #All this means is you got some html back . . .
    }
    else {
    print "Error: " . $res->status_line . "\n";
    }

      Sorry had a bit of a problem with the old html . . .

      From the lwpcook doc http://www.linpro.no/lwp/libwww-perl/lwpcook.pod comes this generic http client - in my time of need this did it for me:

      #!/usr/local/bin/perl -w
      use LWP::UserAgent;
      $myurl = "http://www.perlmonks.org";
      $ua = new LWP::UserAgent; $ua->agent("$0/0.1 " . $ua->agent);
      $ua->agent("Mozilla/8.0");
      # pretend we are very capable browser
      $req = new HTTP::Request 'GET' => "$myurl";
      $req->header('Accept' => 'text/html');
      #send request
      $res = $ua->request($req);
      #check the outcome
      if ($res->is_success) {
      print $res->content;
      #All this means is you got some html back . . .
      }
      else {
      print "Error: " . $res->status_line . "\n";
      }