#!/opt/csw/bin/perl -w print "Content-type: text/html\n\n"; require LWP::Parallel::UserAgent; use HTTP::Request; $timeout = 10; my @ns_headers = ( 'User-Agent' => 'Mozilla/4.76 [en] (Win98; U)', 'Accept' => 'text/html, text/plain,', 'Accept-Charset' => 'iso-8859-1,*,utf-8', 'Accept-Language' => 'en-US', ); my $reqs = [ HTTP::Request->new('GET', "http://www.google.ca", [@ns_headers]), HTTP::Request->new('GET', "http://advertising.microsoft.com/microsoft-adcenter?s_int=US_20070401_livesearchResults_smh_001", [@ns_headers]), ####UN-COMMENT THIS and it wont work ###### HTTP::Request->new('GET', "http://advertising.microsoft.com/search/", [@ns_headers]), ]; my $pua = LWP::Parallel::UserAgent->new(); $pua->in_order (1); # handle requests in order of registration $pua->duplicates(0); # ignore duplicates $pua->timeout (2); # in seconds $pua->redirect (1); # follow redirects foreach my $req (@$reqs) { print "Registering '".$req->url."'
\n"; if ( my $res = $pua->register ($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"; print "and the content is
\n"; print "---------------------------
---------------------------
\n"; }