Return to Snippet

Revision: 19948
at November 3, 2009 19:09 by rowntreerob


Initial Code
#!/usr/bin/perl

  require LWP::Parallel::UserAgent;
  use HTTP::Request; 

  my $pua = LWP::Parallel::UserAgent->new();
  $pua->in_order  (1);  # handle requests in order of registration
  $pua->duplicates(0);  # ignore duplicates
  $pua->timeout   (8);  # in seconds
  $pua->redirect  (1);  # follow redirects
   $pua->max_hosts(5); # sets maximum number of locations accessed in parallel
  $pua->max_req  (5); # sets maximum number of parallel requests per host

  my(@reqs) = <>; # read input file from step 1 
  
   foreach my $req (@reqs) {
#    print "Registering $req \n";
    if ( my $res = $pua->register (HTTP::Request->new('GET', $req) ) ) { 
        print STDERR $res->error_as_HTML; 
    }  
  }
  my $entries = $pua->wait();

  foreach (keys %$entries) {
    my $res = $entries->{$_}->response;
    print "Answer for '",$res->request->url, "' was \t", $res->code,": ",
          $res->message,"\n";
  }

Initial URL

                                

Initial Description
source for perl file that is step 2

Initial Title
run 'linkcheck' on bookmarks 2 of 2

Initial Tags
perl

Initial Language
Perl