Using an Auth Proxy and WWW Mechanize

Fat Tom

Like A Boss
Sep 27, 2008
1,239
35
0
Oregon
Code:
use WWW::Mechanize;


$bot = WWW::Mechanize->new(                
    onwarn => new,
    onerror => undef,
    autocheck => undef,
    );
    
    
    
    use MIME::Base64;


$bot->default_header(
        Authorization => 'Basic ' . encode_base64( 'user' . ':' . 'pass' ) );

    $bot->credentials( 'user', 'password');
    $bot->proxy('http','http://user:pass@75.8.1.2:51807');

    my $url = 'http://whatsmyip.net/';
    
          my $response = $bot->get($url);
    
        my $content = $bot->content;
    
    
    
    
        
    print $content;
I just get a timeout because the proxy host packetflip.com rejected my connection..

Now i've experimented with hundreads of variations of this trying to get it to work, played with putting in the realm, taking it out.. tried to get ENV{'HTTP_PROXY'} working as well - couldn't seem to get it to work.

The proxies are squid proxies and I've tried them in the connection area of the browser and they prompt for a credential style login. (which is where I figured out the realm).

I've tried everything on the first 5 pages of google for all the following keywords "perl www mechanize auth proxy" , "auth proxy perl lwp".

My code has to run in mechanize, but I also must have proxy support.