perl下载文件和图片

文件:

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 open t.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 "不能下载.."; #第一个参数是路径,后面的是文件

相关文章

1. 如何去重 #!/usr/bin/perl use strict; my %hash; while(...
最近写了一个perl脚本,实现的功能是将表格中其中两列的数据...
表的数据字典格式如下:如果手动写MySQL建表语句,确认麻烦,...
巡检类工作经常会出具日报,最近在原有日报的基础上又新增了...
在实际生产环境中,常常需要从后台日志中截取报文,报文的形...
最近写的一个perl程序,通过关键词匹配统计其出现的频率,让...