Created
February 22, 2019 13:57
-
-
Save kitt-vl/bad293c95af595b485a87ad78489dd09 to your computer and use it in GitHub Desktop.
perl juick_b.pl login
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
use Mojo::Base -base; | |
use ojo; | |
my $link = shift; | |
my $url = 'https://juick.com/' . $link; | |
binmode STDOUT, ':utf8'; | |
mkdir 'data' unless -d 'data'; | |
while($url){ | |
my $dom = g($url)->dom; | |
$dom->find('section#content article')->each(sub{ | |
my $post_link = $_->at('div.msg-ts a')->{href}; | |
say $post_link; | |
my ($post_num) = $post_link =~ /(\d+)/; | |
my $post = g('https://juick.com' . $post_link)->dom; | |
my $post_file = 'data/' . $post_num . '.html'; | |
my $post_html = $post->to_string; | |
utf8::encode($post_html); | |
f($post_file)->spurt($post_html) unless -f $post_file; | |
}); | |
my $next = $dom->at('p.page a'); | |
if($next){ | |
$url = 'https://juick.com/' . $link . '/' . $next->{href}; | |
say $url; | |
}else{ | |
$url =''; | |
say "BACKUP $link JUICK FINISHED!"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment