文件:
use LWP::Simple;
$name="成都";
$url="http://192.168.1.213:8080/WellsoftTest/servlet/Httpservletwell?bz=k&name=$name&index=0";
$coont =get($url);
die "not found link.." if(!defined($coont));#如果是null
open $file,">t.txt" or die "couldn't opent.txt ..n";
print $file $coont;
print "print succeed...n";
close($file);
print "succeed,File is t.txt, exit.....";
<>
图片:
use LWP::Simple;
$url="http://192.168.1.213:8080/ERweima/servlet/SendImageServlet?id=1";
$count=undef;
$count=get($url);
die "下载为空" unless defined $count;
open $file,">12.jpg";
binmode $file; #二进制化
print $file $count;
close($file);
print "请求完成,结束";
<>;
有个函数可以省去很多步
getstore($url,"images/$filename") or die "不能下载..";#第一个参数是路径,后面的是文件