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";
}
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/' );
来源:https://stackoverflow.com/questions/542588/how-can-i-handle-proxy-servers-with-lwpsimple