In Japan, people like to set up image boards which are like a simple forum where pretty much anyone can upload a picture. People can also add comments to these pictures. It's a simple and fun system.

People use these image boards to post pictures of all kinds of things, but mostly, they're used to post hotties. (No surprise there, I'm sure.) In this Cool Use For Perl(TM), WWW::Mechanize is used to crawl an image board that specializes in pictures of Sayuri Anzu who is a popular model.

This script will find download all the images posted up on this board on the first run. This script can also be run again at a later date to get new pictures that have been uploaded since the last time the script was run. It's a lot easier than doing right-click, save about 200 times, that's for sure.

#!/usr/bin/perl -w use strict; use WWW::Mechanize; use File::Basename; # load the image board my $mech = WWW::Mechanize->new(); $mech->get("http://uomimi.s3.x-beat.com/imgboard/imgboard.cgi"); # the first page has fewer forms than the rest of the pages. my $which_form = 4; # let's see how deep this goes. do { # get all the image links my @anzu = $mech->find_all_links(url_regex => qr/img-box.*\.jpg$/); foreach (@anzu) { my $filename = basename($_->url); unless (-e $filename) { # download (if we don't have it already) print "$filename\n"; $mech->get($_->url_abs, ':content_file' => $filename); $mech->back(); } else { # quit (if we've already got this) exit 0; } } # go to the next page if ($mech->form_number($which_form)) { $mech->submit; $which_form = 6; } else { $which_form = 0; } # repeat until we can't go any further } until ($which_form == 0); # vim:sts=2 sw=2 expandtab

In reply to Use WWW::Mechanize to Download Pictures of Sayuri Anzu by Anonymous Monk

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.