How can I handle proxy servers with LWP::Simple?

一曲冷凌霜 提交于 2019-12-01 05:02:51

问题


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";
}

回答1:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!