Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何向此脚本添加代理支持?
use LWP::Simple; $url = "http://stackoverflow.com"; $word = "how to ask"; $content = get $url; if($content =~ m/$word/) { print "Found $word"; }
访问底层 LWP::UserAgent 对象并设置代理。LWP::Simple 导出$ua变量,因此您可以这样做:
$ua
使用 LWP::Simple qw( $ua get ); $ua->proxy('http', 'http://myproxy.example.com'); 我的 $content = get('http://www.example.com/');