While we are at it:

#!perl use strict; use warnings; no warnings 'uninitialized'; use LWP::UserAgent; use HTTP::Cookies; if (!@ARGV or $ARGV[0] =~ m{^[-/]h(elp)?$} or $ARGV[0] =~ m{^[-/]\?$}) + { print <<'*END*'; getimagesx.pl [-r referer] url [prefix [-r referer] url prefix] ... downloads all files in the sequence = finds the last number in the + URL and keeps incrementing the number and downloading until it fails three times in a row. The file will be named according to the part + of the URL following the last slash. If you specify just the prefix then the prefix will be prepended t +o the file names. If you specify the -r followed by a URL then that URL will be downloaded, cookies remembered and the URL will be sent to the server as the HTTP_REFERER with the image requests. *END* exit; } my $ua = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, timeout => 60, agent => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; (R1 1 +.3); .NET CLR 1.0.3705)', cookie_jar => HTTP::Cookies->new(), ); our $referer = ''; while ($ARGV[0] =~ m{^[-/]r}) { shift(@ARGV); $referer = shift(@ARGV); if ($referer !~ /##/) { our $result = $ua->get( $referer, ':content_file' => 'referer. +html'); if ($result->code() != 200) { die "Failed to load the referer $referer\n"; } } } while (@ARGV) { my $url = shift(@ARGV); if ($ARGV[0] =~ m{^[-/]r}) { shift(@ARGV); $referer = shift(@ARGV); } my $prefix = shift(@ARGV); if ($ARGV[0] =~ m{^[-/]r}) { shift(@ARGV); $referer = shift(@ARGV); } if (! defined $prefix and $url =~ m{([^/]+)/\d+\.\w+$}) { $prefix = $1; print "Automatic prefix '$prefix'\n"; } my $suffix = ''; if ($prefix =~ m{^(.*)/(.*)$}) { ($prefix, $suffix) = ($1, $2); } if ($url =~ m{^(.*/)(.*?)(\d+)([^0-9]*)$}) { my ($url_beg, $file, $num, $file_end) = ($1,$2,$3,$4); my ($result, $errors); #print "Referer: $referer\n\n"; while ($errors < 10) { local $referer = $referer; if ($referer =~ s/##/$num/g) { #print "Load referer: $referer\n"; $result = $ua->get( $referer, ':content_file' => 'refe +rer.html'); if ($result->code() != 200) { die "Failed to load the referer $referer\n"; } } if ($file =~ /[\&\?]/) { print $url_beg.$file.$num.$file_end," => ",$prefix.$nu +m.$file_end.$suffix,"\n"; $result = getstore($url_beg.$file.$num.$file_end, $pre +fix.$num.$file_end.$suffix); } else { print $url_beg.$file.$num.$file_end," => ",$prefix.$fi +le.$num.$file_end.$suffix,"\n"; $result = getstore($url_beg.$file.$num.$file_end, $pre +fix.$file.$num.$file_end.$suffix); } if ($result == 200) { $errors = 0; } else { $errors++; print "\t$result\n"; } $num++; } print "LAST RESULT: $result\n"; } else { my $file = $url; $file =~ s{^.*/}{}; $file = $prefix . $file; if ($file) { getstore( $url, $file); } else { print STDERR "Can't download directories! ($url)\n"; } } } use Data::Dumper; sub getstore { my ($url, $file) = @_; $file =~ s{(?:~(\d+))?(\.\w+)$}{'~' . ($1+1) . $2}e while (-e $fil +e); my $result = $ua->get($url, ':content_file' => $file, referer => $ +referer); return $result->status_line() if $result->code() != 200; if (wantarray()) { return (200, $result->content_type); } else { if ($result->content_type =~ /^text/i) { print "Bloody bastards. They do not return proper HTTP sta +tus!\n"; # unlink $file; return 404; } return 200; } }
Just in case you wanted all images in a series ;-)


In reply to Re: Swimsuits2006 by Jenda
in thread Swimsuits2004 by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.