Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

LWP::Simple request through a proxy

by freak (Initiate)
on May 04, 2004 at 10:53 UTC ( #350285=perlquestion: print w/replies, xml ) Need Help??

freak has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: LWP::Simple request through a proxy
by Abigail-II (Bishop) on May 04, 2004 at 12:05 UTC
    Your code isn't doing an LWP::Simple request. It's doing its request through LWP::UserAgent (LWP::Simple will use LWP::UserAgent itself as well). Do one to three things:
    • Forget about LWP::Simple. You seem to cope with LWP::UserAgent fine.
    • Use LWP::Simple, and have it export $ua. Set up the proxy through $au, as in your code (But the method above is just as easy).
    • Either use LWP::UserAgent or LWP::Simple as described above, and setup the proxy using environment variables and a call to $au -> env_proxy.
    Futher note that the second argument of the proxy method must be the proxy you are using - not the site you want to reach via a proxy.

    Abigail

      Step two above is exactly what I wanted but I wasn't quite sure exactly what was required but I am now so for others for future reference:
      # use proxy (comment out if not) my %proxy = ( host => 'http://proxy:8080' ); use LWP::Simple qw(mirror RC_OK RC_NOT_MODIFIED $ua); $ua->proxy(http => "$proxy{host}") if (defined $proxy{host});
      You can see I'm just interested in using mirror.
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: LWP::Simple request through a proxy
by dave_the_m (Monsignor) on May 04, 2004 at 11:11 UTC
    Well, the code looks plausible, except that the value in $x should be the URL of the proxy server, while the argument to get() should be the URL of the site you want to get from.
    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2023-01-31 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?