Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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.

Comment on multiple proxies with LWP::UserAgent
Re: multiple proxies with LWP::UserAgent
by cLive ;-) (Parson) 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', "http://search.cpan.org/" ); my $res = $ua->request($req); next unless $res->is_success; print $res->decoded_content; last; # Update }

    hth,
    PooLpi

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://699981]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2014-07-29 06:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls