Created
October 11, 2018 04:12
-
-
Save unstabler/17cfa99ab3433c28bd0ebba3aa357292 to your computer and use it in GitHub Desktop.
crawl images from http://pic.linefriends.com
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 5.010; | |
use utf8; | |
use strict; | |
use warnings; | |
use JSON; | |
use LWP::UserAgent; | |
sub LIST_URL { | |
my $page = shift; | |
sprintf('http://pic.linefriends.com/api/v1/list?p=%d&tag=brown&from=P/1.0.0', $page); | |
} | |
my $ua = LWP::UserAgent->new; | |
my $page = 1; | |
while (1) { | |
my $raw_res = $ua->get(LIST_URL($page)); | |
die $raw_res->content unless $raw_res->is_success; | |
my $json = JSON::from_json($raw_res->content); | |
my @image_list = @{$json->{list}}; | |
last unless scalar(@image_list); | |
for my $image (@image_list) { | |
my $url = $image->{fname}; | |
my $filename = (split '/', $url)[-1]; | |
printf("writing %s => %s\n", $filename, $url); | |
$ua->mirror($url, $filename); | |
} | |
$page++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
20181011 기준 브라운 태그된 이미지들