我试图抓取位于此处的图像并将其保存在我的服务器中,每天几次,就像我“右键单击”图像并将其保存在我的桌面上一样。我决定使用 perl 脚本来执行此操作,这是我到目前为止所写的:
use Image::Grab;
$pic->regexp('.*\.png');
$pic->search_url('http://www.reuters.wallst.com/enhancements/chartapi/index_chart_api.asp?symbol=.SPX&headerType=quote&width=316&height=106&duration=3');
$pic->grab;
open(IMAGE, ">index_chart_api.png") || die"index_chart_api.png: $!";
binmode IMAGE; # for MSDOS derivations.
print IMAGE $pic->image;
close IMAGE;
通过 ssh 运行它后,我收到此错误:Can't call method "regexp" on an undefined value at line 2
任何人都知道这行“$pic->regexp('.*.png');”有什么问题 或者如何正确地从服务器上的提到的 url 抓取和保存这个图像(index_chart_api.png)?
感谢您对此的任何帮助。