Created
July 16, 2012 10:42
-
-
Save soh-i/3122082 to your computer and use it in GitHub Desktop.
ラーメン二郎の画像をinstagramから700枚くらい集めた
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 5.17.0; | |
| use LWP::UserAgent; | |
| use LWP::Simple; | |
| use JSON qw/decode_json/; | |
| my $uri = URI->new('http://search.twitter.com/search.json'); | |
| my $search_query = 'ラーメン二郎+instagr.am'; | |
| for my $date ( qw/8 9 10 11 12 13 14 15 16/ ) { | |
| $uri->query_form( | |
| lang => 'ja', | |
| q => "$search_query", | |
| rpp => "1500", | |
| page => "1", | |
| until => "2012-07-$date", | |
| ); | |
| my $ua = LWP::UserAgent->new; | |
| my $res = $ua->get($uri); | |
| my $json = decode_json ( $res->content ); | |
| if ( defined $json ) { | |
| foreach my $tw ( @{ $json->{results} } ) { | |
| my $text = $tw->{text}; | |
| my $date = $tw->{created_at}; | |
| $date =~ s/\s+|\s//g; | |
| if ( defined $text ) { | |
| $text =~ m/(http\:.+)/; | |
| my $url = $1 if defined $1; | |
| my $html = get($url); | |
| if ( $html ) { | |
| $html =~ m/\<img\sclass\=\"photo\"\ssrc\=\"(http.+)\"\s\/\>/; | |
| my $instagram = $1 if defined $1; | |
| my $img = get($instagram); | |
| open OUT, '>', "./img/$date.jpg"; | |
| binmode OUT; | |
| print OUT $img; | |
| say "Done...$date"; | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment