如何使用LWP :: Simple处理代理服务器?

loc*_*ost 4 perl proxy lwp

如何为此脚本添加代理支持?

use LWP::Simple;

$url = "http://stackoverflow.com";
$word = "how to ask";
$content = get $url;
if($content =~ m/$word/)
{
print "Found $word";
}
Run Code Online (Sandbox Code Playgroud)

bri*_*foy 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/' );