Search code examples
perlproxywww-mechanize

How to do I use a web proxy with Perl's WWW::Mechanize?


I'm trying to use WWW::Mechanize with a proxy server, but seems like I cant get it to work. Since Mechanize is a subclass of LWP::UserAgent, I've been reading about the proxy thing over link text

I have a list of proxies, for example:

74.87.151.157:8000  
69.171.152.25:3128  
190.253.82.253:8080 
189.11.196.221:3128 
41.234.205.201:8080

I have no idea how to use them.

Thanks,


Solution

  • This example sets a HTTP-proxy:

    my $mech  = WWW::Mechanize->new();
    my $proxy = '74.87.151.157:8000';
    
    $mech->proxy('http', "http://$proxy");