如何为此脚本添加代理支持?
use LWP::Simple;
$url = "http://stackoverflow.com";
$word = "how to ask";
$content = get $url;
if($content =~ m/$word/)
{
print "Found $word";
}
答案 0 :(得分:13)
访问底层LWP :: UserAgent对象并设置代理。 LWP :: Simple导出$ua
变量,以便您可以这样做:
use LWP::Simple qw( $ua get ); $ua->proxy( 'http', 'http://myproxy.example.com' ); my $content = get( 'http://www.example.com/' );