Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

•Re: Swimsuit issue

by merlyn (Sage)
on Feb 26, 2002 at 01:24 UTC ( #147451=note: print w/ replies, xml ) Need Help??


in reply to Swimsuit issue

Ow ow owww! Why all the forking? Here's what I used for 2002:

use strict; $|++; use LWP::Simple; my @models = qw( ana_beatriz audrey bridget chandra ehrinn elsa heidi isabeli josie melissa molly petra shakara vanessa veronica yamila ); for my $model (@models) { for my $id (1..15) { my $url = sprintf "http://i.cnn.net/si/features/2002/swimsuit/imag +es/". "gallery/%s/lg/%d.jpg", $model, $id; my $file = "$model-$id.jpg"; print "$url => $file: "; print +mirror($url, $file), "\n"; } }
And here they are for 2001, still grabbable:
use strict; $|++; use LWP::Simple; my @models = qw( amy aurelie daniela elsa fernanda heidi josie lujan michelle molly noemie shakara shirley veronica yamila ); for my $model (@models) { for my $id (1..9) { my $url = sprintf "http://sportsillustrated.cnn.com/features/2001/ +swimsuit/gallery/%s/%s_%d_lg.jpg", $model, $model, $id; my $file = "$model-$id.jpg"; print "$url => $file: "; print +mirror($url, $file), "\n"; } }

-- Randal L. Schwartz, Perl hacker


Comment on •Re: Swimsuit issue
Select or Download Code
Re: +Re: Swimsuit issue
by vladb (Vicar) on Feb 26, 2002 at 03:46 UTC
    Don't really know why, but I found this piece of Perl code very amusing:
    for my $model (@models) { # do stuff... }
    Don't take it as a vulgar comment though ;-)

    "There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith
Re: •Re: Swimsuit issue
by elwarren (Curate) on Feb 26, 2002 at 16:14 UTC
    Bonus points: clicking on "dl code" and hitting "open from here" will do the work of downloading all them for you.

    I just meant to open the script in my editor, really :-)
•Re: •Re: Swimsuit issue
by merlyn (Sage) on Feb 19, 2003 at 22:21 UTC
    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.

      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.

      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
Node Status?
node history
Node Type: note [id://147451]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2015-07-04 20:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls