Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

multiple proxies with LWP::UserAgent

by pingpongd (Initiate)
on Jul 24, 2008 at 22:32 UTC ( #699981=perlquestion: print w/replies, xml ) Need Help??
pingpongd has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, i'm trying to utilize multiple proxies with UserAgent. Is it possible to have it look at a list of proxy addresses and try to connect to a different address when the currently used proxy address is inactive? I want it to continue where it left off with the new proxy address, I do not want to manually type in the next working proxy address and start where it left off.

Replies are listed 'Best First'.
Re: multiple proxies with LWP::UserAgent
by cLive ;-) (Prior) on Jul 24, 2008 at 23:53 UTC
    My black hat radar is pinging right now. Care to explain the all too innocent real reason that you need this now to save being tarred and feathered later?
      I'm uploading a lot of data through the databases in metaweb and freebase, If you've used their services before you'll know that you can't upload lots of data at one time, I'm trying to write a script that will just upload all the datasets that I have overnight and I wouldn't have to worry about manually changing things. Do you know if it's possible to do something like that?
Re: multiple proxies with LWP::UserAgent
by poolpi (Hermit) on Jul 25, 2008 at 10:59 UTC

    It works like this :

    #!/usr/bin/perl -w use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); my @proxies = ( 'http://proxy.no1:8001/', 'http://proxy.no2:8002/', 'http://proxy. +no3:8003//', 'http://proxy.no4:8004/' ); for (@proxies) { $ua->proxy( [ 'http', 'ftp' ] => $_ ); my $req = HTTP::Request->new( 'GET', "" ); my $res = $ua->request($req); next unless $res->is_success; print $res->decoded_content; last; # Update }


    'Ebry haffa hoe hab im tik a bush'. Jamaican proverb

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://699981]
Approved by ikegami
NodeReaper serves mincemeat tarts with the cider

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2018-01-22 16:33 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (235 votes). Check out past polls.