tags:

views:

359

answers:

1

How can I add proxy support to this script?

use LWP::Simple;

$url = "http://stackoverflow.com";
$word = "how to ask";
$content = get $url;
if($content =~ m/$word/)
{
print "Found $word";
}
+6  A: 

Access the underlying LWP::UserAgent object and set the proxy. LWP::Simple exports the $ua variable so you can do that:

use LWP::Simple qw( $ua get );
$ua->proxy( 'http', 'http://myproxy.example.com' );
my $content = get( 'http://www.example.com/' );
brian d foy