Created
April 4, 2012 08:03
-
-
Save sharl/2299606 to your computer and use it in GitHub Desktop.
haruchan!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use POSIX qw(strftime); | |
use LWP::UserAgent; | |
use Data::Dumper; | |
my $save_dir = $ENV{HOME} . '/Dropbox/haruchan/'; | |
my $TARGET = 'http://cgi2.nhk.or.jp/nw9/haruchan/saijiki/index.cgi?entry=%Y%m%d'; | |
my $HARUCHAN = 'http://cgi2.nhk.or.jp/nw9/data/saijiki/images/%Y%m%d_pg7.jpg'; | |
my $MY_HARU = '%Y%m%d_pg7.jpg'; | |
my $target = strftime($TARGET, localtime); | |
my $haruchan = strftime($HARUCHAN, localtime); | |
my $my_haru = strftime($save_dir . $MY_HARU, localtime); | |
if (! -f $my_haru) { | |
my $ua = LWP::UserAgent->new; | |
my $head = $ua->head($haruchan, 'Referer' => $target); | |
if (! $head->previous) { | |
$ua->get($haruchan, ':content_file' => $my_haru, 'Referer' => $target); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment