我使用此代码来保存图像使用Image::Grab特定的URL。但图像被保存在0字节中,所以没有图像。Perl:保存图像从网络
#!/usr/bin/perl
use Image::Grab;
$pic->url('hhttp://www.vikingskipet.no/cam_1.jpg')
$pic->grab;
# Now to save the image to disk
$time = time();
open(IMAGE, ">$time.jpg") || die"$time.jpg: $!";
binmode IMAGE; # for MSDOS derivations.
print IMAGE $pic->image;
close IMAGE;
我希望有人能帮助我。我使用cronjobs来每分钟运行脚本。
'使用严格的;使用警告;' - 除非您在发布之前将样本过多地剪下来,否则'$ pic'未被初始化。 (并检查网址。) – Mat 2012-03-31 10:06:22