Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-25 05:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found