Skip to content

Instantly share code, notes, and snippets.

@t-kashima
Created June 16, 2012 23:57
Show Gist options
  • Save t-kashima/2942891 to your computer and use it in GitHub Desktop.
Save t-kashima/2942891 to your computer and use it in GitHub Desktop.
はてなフォトから画像を取得する
#!/usr/bin/env perl
use strict;
use warnings;
use LWP::UserAgent;
use XML::Simple;
use Data::Dumper;
sub main {
my $baseurl = "http://f.hatena.ne.jp/userlist";
my $page = $ARGV[0];
my $ua = LWP::UserAgent->new;
my $url = URI->new($baseurl);
$url->query_form(
mode => 'rss',
type => 'image',
page => $page
);
my $res = $ua->get($url);
if ($res->is_success) {
my $xml = XML::Simple->new;
my $hash = $xml->XMLin($res->content);
for my $item (@{ $hash->{item} }) {
print $item->{'hatena:imageurl'} . "\n";
}
}
}
&main;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment