4
我正在研究Perl腳本以獲得「天文學圖像」並將其設置爲我的壁紙。然後我會設置一個cronjob爲我每天做這件事。但是我很難讓腳本沿着圖像鏈接進入全尺寸圖像,只有這樣,才能下載它。 我是想這樣的事情代碼波紋管(有記住,我只是一個Perl的初學者誰不知道很多關於Perl的正則表達式):與WWW的圖像鏈接後的麻煩::機械化
#!/usr/bin/perl -w
use strict;
use warnings;
use WWW::Mechanize;
my $url = "http://apod.nasa.gov/apod/astropix.html";
my $mech = WWW::Mechanize->new();
$mech->get($url);
#debugging
if ($mech->follow_link(url_regex=>qr/\.(?:jpg|png)$/)){
print "Following the image link...";
}else{
print "Couldn't find the link...";
}
my @img = $mech->find_image(alt_regex => qr/image/i);
foreach my $img(@img){
$mech->get($img->url, ':content_file'=>'astro.jpg');
}
print "\n";
exit(0);
任何幫助,將不勝感激!
參見http://perlmonks.org/?node_id=978153 –