Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Need help using WWW::Mechanize to access proxy and authentication

by sunslinger (Initiate)
on Jul 11, 2006 at 04:21 UTC ( #560305=perlquestion: print w/ replies, xml ) Need Help??
sunslinger has asked for the wisdom of the Perl Monks concerning the following question:

Hi fellow monks,

Ok, here's where I stand at the moment. I'm trying to access an intranet web page in order to fill in some forms but the obstacle at the moment is the company's proxy and authentication for the proxy. In my code, i tried accessing google with the same failed result. And btw, I do not know how to get the realm field under $mech->credentials. If someone could enlighten me, it would be very much appreciated!!

Here's my code:

use WWW::Mechanize; use LWP::UserAgent; use MIME::Base64; use strict; my $url = 'http://www.google.com'; my $proxy = 'http://someproxy.com:80/'; my $alias = 'Windows IE 6'; my $username = 'user'; my $password = 'passwd'; my $mech = WWW::Mechanize->new( autocheck => 1, agent => $alias); $mech->proxy(['http', 'ftp'], $proxy); $ENV{'http_proxy'} = $proxy; my @args = ( Authorization => "Basic" . MIME::Base64::encode( $username . ":" . $pa +ssword ) ); $mech->credentials( $proxy, "MOCPROXY04", $username, $password ); $mech->get( $url ); $mech->get( $url, @args ); my $response = $mech->response(); for my $key ( $response->header_field_names() ) { print $key, ":", $response->header( $key ), "\n"; }

Here's the compilation result:

Error GETing http://www.google.com: Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied. ) at mech.pl line 22

Edited by planetscape - added code tags

( keep:0 edit:23 reap:0 )

Comment on Need help using WWW::Mechanize to access proxy and authentication
Select or Download Code
Re: Need help using WWW::Mechanize to access proxy and authentication
by aufflick (Deacon) on Jul 11, 2006 at 06:21 UTC
    The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied.
    It may well be that the Microsoft ISA server is configured to require NTLM authentication. I've never been able to get that to work with LWP. See NTLM - Not Telling Linux Much.

      Hi from your post it looks like your proxy needs authorisation.
      I dont know much about WWW::Mechanize but from my experience with LWP and proxy i think setting up
      $ENV{HTTP_PROXY} which you have set
      $ENV{HTTP_PROXY_USERNAME} and
      $ENV{HTTP_PROXY_PASSWORD}
      thease enviornment variables will help you.

Re: Need help using WWW::Mechanize to access proxy and authentication
by planetscape (Canon) on Jul 11, 2006 at 22:08 UTC

    Please note that, in general, it is best to post follow-up questions as replies to their original thread.

    HTH,

    planetscape

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-12-21 11:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (104 votes), past polls