Advertisement
Guest User

gelbooru-grabber.pl

a guest
Oct 23rd, 2013
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.88 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use LWP::Simple;
  5.  
  6. die "Usage: $0 [tags] [directory for pics]" if @ARGV != 2;
  7.  
  8. my $tags = shift @ARGV;
  9. my $path = shift @ARGV;
  10. mkdir $path unless -d $path;
  11.  
  12. ########################
  13.  
  14. my $maxcount;
  15. my $content = get("http://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=0&tags=$tags");
  16. $content =~ /<posts count="(\d+)"/;
  17. $maxcount = $1;
  18.  
  19. my $page = 0;
  20.  
  21. for(my $pid = 0; $pid*100 <= $maxcount; $pid++) {
  22.     ++$page;
  23.     # $tags =~ s/\s| /\+/;
  24.     my $content = get("http://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=100&tags=$tags&pid=$pid");
  25.     print "----page $page loaded\n";
  26.    
  27.     while($content =~ m!file_url="http://(.*?)\.gelbooru.com/images/(\d+)/(.*?\.(jpe?g|png|gif))"!gi) {
  28.         getstore("http://$1.gelbooru.com//images/$2/$3", $path.$3);
  29.         print $3." ---------loading\n";
  30.     }
  31.    
  32.     print "----images from $page page loaded\n";
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement