Resolved:

First of all, thanks everyone for your help.

1.Client used up all traffic on rented proxies, without warning me about it, so LWP::UserAgent was not able to use rented parent-proxies.

2. In http://proxy... link, last slash was missing, I tried to add it\delete it but it was useless due to a "traffic issue", when this issue was resolved, I added the slash again and... voila, it works! In other words:

my $cur_proxy = "http://$valid_routes[$j]"; # <--- Not working; my $cur_proxy = "http://$valid_routes[$j]/"; #<--- Works as a charm
May be it's not supposed to be an issue, but for me it works somehow only with closing slash, atleast when I tried it. I have some remote proxies for my needs, and I'm trying to use them simultaneously. Script should to change proxy used for serving requests before each new request. Proxy IP's are stored in array and then should be chosen randomly. I tried this appoach for UserAgent rotation and it worked, but it's not working for for proxy rotation. I hope some one can help me with this, thanks in advance.
my (@agents, @raw_routes, @valid_routes); open( AGENTS, "<", "/etc/squid/ua.cfg" ); while( <AGENTS> ) { s/#.*//; next if /^(\s)*$/; chomp; push @agents, $_; } close(AGENTS); open( ROUTES, "<", "/etc/squid/repeater/lib/routes.cfg" ); while( <ROUTES> ) { s/#.*//; next if /^(\s)*$/; chomp; push @raw_routes, "$_,ENABLED"; } close(ROUTES); my $ua = LWP::UserAgent->new(); sub cb { my($request, $ua, $h) = @_; $#valid_routes = -1; my $i = $#agents + 1; $i = rand($i); $i = int $i; foreach my $item (@raw_routes) { $item =~ s/,ENABLED//; push @valid_routes, $item unless $item =~ m/DISABLED/; } my $j = $#valid_routes + 1; $j = rand($j); $j = int $j; my $cur_agent = $agents[$i]; my $cur_proxy = "http://$valid_routes[$j]"; $request->proxy_authorization_basic( 'uname', 'passwd'); $ua->proxy(['http'], $cur_proxy); $request->header('User-Agent' => $cur_agent); $ua->timeout(120); } $ua->add_handler( request_preprepare => \&cb, { m_method => 'GET' } );

In reply to [Resolved]Proxy link rotation by kazak

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.