Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use warnings;
- sub norm($) {
- my $n = shift;
- $n = 0 unless $n;
- $n =~ s/x/\./g;
- return $n;
- }
- our @main;
- our $siteroot = "http://zoomgirls.net";
- our $get_only_biggest = 1;
- our %rdb = (
- '1280x1024' => 1.25,
- '800x600' => 1.33,
- '1024x768' => 1.33,
- '1152x864' => 1.33,
- '1280x960' => 1.33,
- '1600x1200' => 1.33,
- '1920x1440' => 1.33,
- '1280x800' => 1.6,
- '1440x900' => 1.6,
- '1680x1050' => 1.6,
- '1920x1200' => 1.6,
- '1920x1200' => 1.6,
- '2560x1600' => 1.6,
- '1280x720' => 1.77,
- '1366x768' => 1.77,
- '1600x900' => 1.77,
- '1920x1080' => 1.77,
- );
- push @main, "${_}_girls" for ('a'..'z');
- push @main, $_ for (
- "anime_and_drawings",
- "babes_and_bikes",
- "babes_and_cars",
- "sexy_girls"
- );
- mkdir("root"); mkdir("pages"); mkdir("walls"); mkdir("pics");
- for my $main_cat (@main) {
- my $corpus = "girls";
- $corpus = $main_cat unless $main_cat =~ /^[a-z]_girls$/;
- mkdir("pics/$corpus");
- my ($url, $file);
- $file = "$main_cat-desktop-wallpapers.html";
- unless (-e "root/$file") {
- $url = "$siteroot/$file";
- system("wget $url -O root/$file") == 0 or die;
- }
- open F, "root/$file" or die;
- my $maxpage = 1;
- while (<F>) {
- while (/desktop-wallpapers\/page\/(\d+)"/g) {
- $maxpage = $1 if $1 > $maxpage;
- }
- }
- close F;
- for my $i (1..$maxpage) {
- $file = "pages/$main_cat-desktop-wallpapers_$i.html";
- unless (-e $file) {
- $url = "$siteroot/$main_cat-desktop-wallpapers/page/$i";
- system("wget $url -O $file") == 0 or die;
- }
- open F, "$file" or die;
- while (<F>) {
- next unless /<div class="thumb"><a href="\/(.+?)-wallpapers.html"><em>\d+ views<\/em>/;
- my $id = $1;
- $file = "$id-wallpapers.html";
- unless (-e "walls/$file") {
- $url = "$siteroot/$file";
- system("wget $url -O walls/$file") == 0 or die;
- }
- open G, "walls/$file" or die;
- print "$file\n";
- my $found = 0;
- my $dlink = undef;
- while (<G>) {
- if (/<a href="\/view\/(.*?).html"/) {
- $dlink = "$1.jpg";
- }
- next unless /and it is available in (.*?)resolutions/;
- my $res = $1;
- $res =~ s/,?\s*$//;
- unless ($res) {
- unless ($dlink) {
- warn "No IMAGE links found!" unless $dlink;
- $found = 0;
- last;
- }
- $found = 1;
- $file = $dlink;
- unless (-e "pics/$corpus/$file") {
- system("wget $siteroot/download/$file -O pics/$corpus/$file") == 0 or die;
- }
- last;
- }
- my %maxr;
- for my $raw (split /, /, $res) {
- die "raw=[$raw/$res]" unless $raw =~ /^(\d+) x (\d+)$/;
- my $r = "$1x$2";
- die "$r not in DB!" unless exists $rdb{$r};
- my $aspect = $rdb{$r};
- $maxr{$aspect} = $r if norm($maxr{$aspect}) < norm($r);
- }
- if ($get_only_biggest) {
- my $mx = '';
- for my $curr (sort values %maxr) {
- $mx = $curr if norm($curr) > norm($mx);
- }
- %maxr = (1 => $mx);
- }
- for my $curr (sort values %maxr) {
- $found = 1;
- $file = "$id-$curr.jpg";
- unless (-e "pics/$corpus/$file") {
- system("wget $siteroot/download/$file -O pics/$corpus/$file") == 0 or die;
- }
- }
- }
- warn "No images found in $file..." unless $found;
- close G;
- }
- close F;
- }
- }
Add Comment
Please, Sign In to add comment