Advertisement
Guest User

gelbooru-grabber.pl

a guest
Oct 22nd, 2013
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.18 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use LWP::Simple;
  5.  
  6. my $tags = 'remilia_scarlet rating:safe -figure -comic -comics -4koma -4enkoma -cosplay'; # теги
  7. my $path = $ENV{HOME}.'/pics/Anime/Touhou/remilia_scarlet/'; # директория, куда складывать пикчи. без /home/$user/
  8. mkdir $path unless -d $path;
  9.  
  10. my $pid = 0;
  11. my $lastpid;
  12.  
  13. ########################
  14.  
  15. # $tags =~ s/\s| /\+/;
  16. my $content = get("http://gelbooru.com/index.php?page=post&s=list&tags=$tags");
  17. $content =~ /;pid=(\d+)" alt="last page"/;
  18. $lastpid = $1;
  19.  
  20. for(my $page = 1; $pid <= $lastpid; $pid += 63) {
  21.     $tags =~ s/\s| /\+/;
  22.     my $content = get("http://gelbooru.com/index.php?page=post&s=list&tags=$tags&pid=$pid");
  23.     print "----page $page loaded\n";
  24.    
  25.     unless($content =~ m!http://.*?\.gelbooru\.com/thumbnails/\d+/thumbnail_!) { sleep(11) and redo; }
  26.    
  27.     while($content =~ m!href="index.php\?page=post&amp;s=view&amp;id=.*?" ><img src="http://(.*?)\.gelbooru\.com/thumbnails/(\d+)/thumbnail_(.*?\.(jpe?g|png|gif))\?\d+" alt="!gi) {
  28.         getstore("http://$1.gelbooru.com//images/$2/$3", $path.$3);
  29.         print $3." ---------loading\n";
  30.     }
  31.    
  32.     print "----images from $page loaded\n";
  33.     ++$page;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement