Skip to content

Instantly share code, notes, and snippets.

@kitt-vl
Created February 22, 2019 13:57
Show Gist options
  • Save kitt-vl/bad293c95af595b485a87ad78489dd09 to your computer and use it in GitHub Desktop.
Save kitt-vl/bad293c95af595b485a87ad78489dd09 to your computer and use it in GitHub Desktop.
perl juick_b.pl login
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