I couldn't resist posting this here -- even though it's at best a code snippet, and I'm less than a duffer, ranker than an armchair -- just cuz the context is so appropriate, in a self-referential sort of way. (Notwithstanding the inadequacies, at least it's short.)
It's a little script to download the cumulative "Cool Uses for Perl" pages and string them into one big page on my HD. Yeah I know. I should've filtered and scraped and WWW-Mechanize'd away all the duplicated headers and footers and sidebars and stuff. A rainy day perhaps ...
#! /usr/bin/perl -w use strict; use warnings; use LWP::Simple; my $url; my $doc; my $path = "http://www.perlmonks.org/?"; my $fn = "coolness.html"; open TO_FILE, ">> $fn" or die ": $!"; for (my $i=0;$i<300;$i+=15) { $url = $path . "next=" . $i . ";node_id=1044"; warn $url, "\n"; $doc = get($url); print TO_FILE $doc; } close TO_FILE;
(But I'm curious, maybe someone knows: could the for( ) loop be replaced by a while(< >) contruct? Looks a bit verbose, that $doc variable shunting inbound pages to the filehandle. Um?)
(Be kind. You were all once newbies too.)
Unconsidered by castaway - already been considered a few times, we're leaving it unapproved.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Cool Uses, re-used
by davido (Cardinal) on Nov 14, 2004 at 17:09 UTC | |
by diotalevi (Canon) on Nov 14, 2004 at 22:54 UTC | |
Re: Cool Uses, re-used
by Your Mother (Archbishop) on Nov 14, 2004 at 18:40 UTC | |
Re: Cool Uses, re-used
by elwarren (Priest) on Nov 15, 2004 at 20:20 UTC |