Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hello Monks, I know this is probably something that probably has been asked quite a few times....I have scanned through a lot of documentation ...a lot of queries posted on various groups etc..But still not able to get through this issue with the proxy on my network. Also the requests are Websensed. Here is a sample script I picked up from the code snippets on perl monks .... but this doesnt work...
#!/usr/bin/perl -w # dget.pl # pod at tail use strict; use LWP::UserAgent; use Getopt::Long; use Pod::Usage; use URI::URL; use LWP::Debug qw(+); my ($opt_help, $opt_man); GetOptions( 'help!' => \$opt_help, 'man!' => \$opt_man, ) or pod2usage(-verbose => 1) && exit; pod2usage(-verbose => 1) && exit if (defined $opt_help); pod2usage(-verbose => 2) && exit if (defined $opt_man); # Begin config parameters my %parm = ( url => shift, outfile => shift, uatimeout => 120, # seconds before giving up on fetch browser => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Geck +o/20020310 ', ); my %proxy = ( host => 'http://proxy.mycomp.com:8080', # http://host.dom:port id => 'mynw\mylogin', # ntdom\userid pass => 'mypasswd', # empty quotes if no proxy auth ); # End config parameters unless(defined $parm{url}) { print "\n Ooot - you forgot to provide a URL !\n"; Ooot(); } unless(defined $parm{outfile}) { print "\n Ooot - your forgot to provide an outfile !\n"; Ooot(); } print "\n Fetching $parm{url}...\n"; my $ua = new LWP::UserAgent; $ua->agent($parm{browser}); $ua->timeout($parm{uatimeout}); $ua->proxy(http => "$proxy{host}") if (defined $proxy{host}); $parm{url} = new URI::URL($parm{url}); my $req = new HTTP::Request "GET" => ($parm{url}); $req->proxy_authorization_basic ($proxy{id}, $proxy{pass}) if (defined $proxy{id}); my $res = $ua->request($req); if ($res -> is_success) { my $rescont = $res->content; open (OUT, ">$parm{outfile}") or die "Error opening $parm{outfile} for write: $!"; print OUT $rescont; close OUT or die "Error closing $parm{outfile}: $!"; } else { my $resmsg = $res->message; print "Error fetching $parm{url}:\n $resmsg\n\n"; exit; } print " Done! Page saved at '$parm{outfile}'\n\n"; sub Ooot { print "\n dget.pl --help", "\n dget.pl --man", "\n", "\n LWP $LWP::VERSION", "\n Perl $]", "\n OS $^O", "\n Program $0", "\n\n", ; exit; } Outputs the following : D:\testperl>perl dget.pl http://google.com out.txt Fetching http://google.com... LWP::UserAgent::new: () LWP::UserAgent::proxy: http http://proxy.mycomp.com:8080 LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://google.com/ LWP::UserAgent::_need_proxy: Proxied to http://proxy.mycomp.com:8080 LWP::Protocol::http::request: () LWP::Protocol::collect: read 623 bytes LWP::Protocol::collect: read 1754 bytes LWP::UserAgent::request: Simple response: Proxy Authentication Require +d Error fetching http://google.com/: Proxy Authentication Required ( The ISA Server requires authorizatio +n to fulfi ll the request. Access to the Web Proxy service is denied. )
Please guide me to the right issue behind this.

In reply to LWP and proxy by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-04-16 16:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found