从 .asp url 抓取图像并保存
我正在尝试抓取位于 此处 每天将其保存在我的服务器中几次,就像我在图像上“右键单击”并将其保存到我的桌面上。我决定使用 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 运行后,我收到此错误:无法在第 2 行对未定义值调用方法“regexp”
任何人都知道这行“$pic->regexp('.*.png');”有什么问题或者如何正确地从服务器上提到的网址抓取并保存此图像(index_chart_api.png)?
感谢对此的任何帮助。
I'm trying to grab the image located here and save it in my server few times per day, just as if I "right-click" on the image and save it on my desktop. I have decided to use perl script to do this, here's what I wrote so far:
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;
After running it via ssh I receive this error: Can't call method "regexp" on an undefined value at line 2
Anyone has any idea what is wrong with this line "$pic->regexp('.*.png');" or how to grab and save this image (index_chart_api.png) from mentioned url on ones server properly ?
Appreciate any help with this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请注意,给出的 URL 在我的浏览器中显示了 PNG 图像,这意味着没有 HTML 可以搜索该图像。原则上,以下脚本应该可以工作:
我使用类似的脚本在波罗的海 - 5 分钟 6 天。
Note that the URL gave shows the PNG image in my browser meaning there is no HTML to search for the image. In principle, then, the following script ought to work:
I used a similar script to produce Norwegian Sun in the Baltic Sea - 6 days in 5 minutes.
您还没有初始化该对象,这就是它未定义的原因。
或类似的事情:
You haven't init the object, that's why it is undefined.
or similar thing: