Hi all, I'm using LWP::Parallel and it works good for me. But I have one curious problem - I want change PUA agent for every request. But I don't know how to to that. Result of this code are 15 txt files, but, content is not what I expect. I'd like to have in TXT something like this:
"HTTP_HOST: 2ge.mine.nu" in every file "HTTP_USER_AGENT: My agent x" where x is number 0-15 Just run this piece of code and you will see. use strict; use warnings; use LWP::Parallel::UserAgent; my $http = 'http://2ge.mine.nu/headers.php'; my $max_hosts = 10; #registration of PARALLEL USER AGENT my $pua = LWP::Parallel::UserAgent->new(); $pua->in_order (0); # handle requests in order $pua->duplicates(0); # ignore duplicates $pua->timeout (10); # in seconds $pua->redirect (0); # follow redirects $pua->max_hosts ($max_hosts); # connect in parallel server $pua->max_req ($max_hosts); # max req per host my $counter = 0; my @agents = map "My agent $_", 1..15; for (my $i=0; $counter<@agents; $i++) { my @reqs_l = (); for (my $j=0; $j<$max_hosts; $j++) { push( @reqs_l,HTTP::Request->new('GET', $http) ); } my $reqs = [EMAIL PROTECTED]; #this could be better? foreach my $req (@$reqs) { if (defined $agents[$counter]) { $pua->agent("$agents[$counter]"); print "Registering agent: ".$counter."\n"; if ( my $res = $pua->register ($req) ) { print STDERR $res->error_as_HTML; } } $counter++; } my $entries = $pua->wait(); my $cnt = 0; foreach (keys %$entries) { print "WRITING content to $cnt.txt\n"; open(OUT,">$cnt.txt"); my $res = $entries->{$_}->response; print OUT $res->content( ); close OUT; $cnt++; } } ---- please if you ahve some idea, what I'm doing wrong, please help me. I tried maybe everything...THANKS! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>