Created
June 16, 2012 23:57
-
-
Save t-kashima/2942891 to your computer and use it in GitHub Desktop.
はてなフォトから画像を取得する
This file contains hidden or 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/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