confused_programmer has asked for the wisdom of the Perl Monks concerning the following question:
#!/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/micros +oft-adcenter?s_int=US_20070401_livesearchResults_smh_001", [@ns_heade +rs]), ####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."'<BR>\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,"<BR>\n"; print "and the content is<BR>\n"; print "---------------------------<BR><TEXTAREA NAME='asdasd' ROWS +='5' COLS='80' WRAP='virtual'>\n"; print $res->content; print "</TEXTAREA>---------------------------<BR>\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: trouble with redirecting
by kyle (Abbot) on Jun 05, 2007 at 19:28 UTC | |
|
Re: trouble with redirecting
by shmem (Chancellor) on Jun 05, 2007 at 18:21 UTC | |
by confused_programmer (Initiate) on Jun 05, 2007 at 18:33 UTC | |
by confused_programmer (Initiate) on Jun 05, 2007 at 18:30 UTC | |
by shmem (Chancellor) on Jun 05, 2007 at 18:39 UTC | |
by confused_programmer (Initiate) on Jun 05, 2007 at 18:45 UTC | |
by shmem (Chancellor) on Jun 05, 2007 at 19:06 UTC |