首页 > 代码库 > perl LWP::UserAgent获取源码与响应

perl LWP::UserAgent获取源码与响应

 1 #!/usr/bin/perl -w
 2 use strict;
 3 use LWP::UserAgent;
 4  
 5 my $useragent = new LWP::UserAgent;
 6 my $url = http://www.baidu.com;
 7 my $request = HTTP::Request->new(GET => $url);
 8 my $repose = $useragent->request($request);
 9 print $repose->as_string;
10 #网站源码
11 print "\n",$repose->status_line, "\n";
12 #响应码

 

perl LWP::UserAgent获取源码与响应