java多线程    Java入门    vsftp    ftp    linux配置    centos    FRP教程    HBase    Html5缓存    webp    zabbix    分布式    neo4j图数据库    

perl读取远程文件lwp安装

use LWP::UserAgent;
 $ua = LWP::UserAgent->new;
 $ua->agent("$0/0.1 " . $ua->agent);
 # $ua->agent("Mozilla/8.0") # pretend we are very capable browser
 
 $req = HTTP::Request->new(
    GET => 'http://www.baidu.com');
 $req->header('Accept' => 'text/html');
 
 # send request
 $res = $ua->request($req);
 print $res->decoded_content;

缺少网络连接库 LWP的时候报错
Can't locate LWP/UserAgent.pm in @INC (you may need to install the LWP::UserAgent module) (@INC contains: /opt/local/lib/perl5/site_perl/5.26/darwin-thread-multi-2level /opt/local/lib/perl5/site_perl/5.26 /opt/local/lib/perl5/vendor_perl/5.26/darwin-thread-multi-2level /opt/local/lib/perl5/vendor_perl/5.26 /opt/local/lib/perl5/5.26/darwin-thread-multi-2level /opt/local/lib/perl5/5.26) at readpiwik.pl line 1.

安装一下


 perl -MCPAN -eshell  
cpan> install Bundle::LWP


This entry was posted in Linux and tagged , . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/perl-read-url-connect-lwp/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力.

Leave a Reply