Gossamer Forum
Home : General : Perl Programming :

using proxy server and get($url). Ideas?

Quote Reply
using proxy server and get($url). Ideas?
Hi guyz,

I am in big trouble ;-)
My ISP limited my server http access by HTTP proxy server.
Ok, my server must get url via proxy. How to perform that on simple Perl script?
Until now I usually use get("http://something.com");
I tryed to hack my script with UserAgent.pm, setting environment variable and then using env_proxy(), but that doesn't work..

Any ideas? Please help ;-)


------------------
rgrdz,
TukBa
ICQ: 1005139
Quote Reply
Re: using proxy server and get($url). Ideas? In reply to
Not sure if you can do it with LWP::Simple. I'd first make sure you set
$ENV{'HTTP_proxy'} = 'http://yourproxy.com';

If that doesn't work, use LWP. Like

use LWP::UserAgent;
use HTTP::Request;
my $ua = new LWP::UserAgent;
my $url = new HTTP::Request ('GET', 'http://someurl.com');

$ua->proxy('http://yourproxy.com');
$resp = $ua->request($url);

print $resp->as_string;

Hope that helps,

Alex