Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

•Re: •Re: Swimsuit issue

by merlyn (Sage)
on Feb 19, 2003 at 22:21 UTC ( [id://236853]=note: print w/replies, xml ) Need Help??


in reply to •Re: Swimsuit issue
in thread Swimsuit issue

And here it is for 2003:
use strict; $|++; use LWP::Simple; my @models = qw( may ana_beatriz yamila isabeli bridget melissa noemie juliana marisa petra sarah daniela audrey molly jessica ); for my $model (@models) { for my $id (0..15) { my $url = sprintf "http://s.a.cnn.net/si/features/2003_swimsuit/" +. "images/gallery/popup/%s_%02d.jpg", $model, $id; my $file = "$model-$id.jpg"; print "$url => $file: "; print +mirror($url, $file), "\n"; } }

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: •Re: Swimsuit issue
by valdez (Monsignor) on Feb 20, 2003 at 10:13 UTC

    I'd like to propose a patch to avoid looping and fetching girls when you're sure there aren't. Please, read your column on that {grin}. Many thanks to larsen for his cooperation in writing this joke.

    :))) Valerio

    32c32,37 < print +mirror($url, $file), "\n"; --- > if (mirror($url, $file) == RC_NOT_FOUND) { > print "not found\n"; > last; > } else { > print "ok\n"; > }

    update: merlyn is ALWAYS right :)

      No the code is deliberately continuing even when I get a 404, because some of the number sequences are not, uhm, sequential. Some of them have a 0 picture, some of them are missing a 4, and so on. No model has over 8 or 9 pix, so I guess I could crank the 15 down to 9.

      Hey, what's the cost of 10 additional 404 probes per model, anyway? It's a fast probe.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

•Re: •Re: •Re: Swimsuit issue
by merlyn (Sage) on Feb 16, 2004 at 18:53 UTC
    And for 2004, only a few minor tweaks needed:
    use strict; $|++; use LWP::Simple; my @models = qw( ana angela bridget carolyn elsa fernanda frankie jessica jessicaw marisa may melissa molly noemie petra veronica yamila ); # http://s.a.cnn.net/si/features/2004_swimsuit/images/gallery/popup/ma +y_03.jpg for my $model (@models) { for my $id (0..15) { my $url = sprintf "http://s.a.cnn.net/si/features/2004_swimsuit/" +. "images/gallery/popup/%s_%02d.jpg", $model, $id; my $file = "$model-$id.jpg"; print "$url => $file: "; print +mirror($url, $file), "\n"; } }

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.


    update: check out the 2005 edition as well.

      When this script got mentioned in the chatterbox today, a bunch of us Monks were on it like ants on jello. In order to even out the server requests I thought a randomizing rendition of the script might help. Subjectively it does seem my fetches (over dialup connection) ARE going a little faster with it. Thus, this:


      #--------------------------------------------------------------------- +- # Based on perl code d/l from Perlmonks node: 329407 # View Original At: # http://www.perlmonks.org/?node=329407&displaytype=displaycode #--------------------------------------------------------------------- +- use strict; $|++; use LWP::Simple; my($file,$url,%potenpics); my @models = qw( ana angela bridget carolyn elsa fernanda frankie jessica jessicaw marisa may melissa molly noemie petra veronica yamila ); for my $model (@models) { for my $id (0 .. 15) { $potenpics{"$model-$id.jpg"} = sprintf "http://s.a.cnn.net/si/features/2004_swimsuit/" . "images/gallery/popup/%s_%02d.jpg", $model, $id; } } while (($file,$url) = each %potenpics) { print "$url => $file: "; unless (-e $file and -s _) { print +mirror($url, $file), "\n" } else { print "skipped, already exists\n"} }

          Soren A / somian / perlspinr / Intrepid
      P.S. Don't forget: I am expecting all the people the people who say I am posting to Perlmonks for the XP to automatically downvote this posting w/o explanation, thanks.

      -- 
      Try my n.y.p.m.blue Perl Monks CSS Theme
      (edit "On-Site CSS Markup" on the User Settings node)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://236853]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-19 15:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found