Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

petdance (2468)

petdance
  andy@petdance.com
http://www.perlbuzz.com/
AOL IM: petdance (Add Buddy, Send Message)
Yahoo! ID: petdance (Add User, Send Message)
Jabber: petdance@gmail.com

I'm Andy Lester, and I like to test stuff. I also write for the Perl Journal, and do tech edits on books. Sometimes I write code, too.

Journal of petdance (2468)

Monday January 26, 2004
10:21 PM

Today's Mech doodad: Fetching the new Code Complete

[ #17025 ]
Steve McConnell, author of the landmark I has put up the chapters for the 2nd edition in PDF format on his website. I needed to download them to take to Kinko's to have printed, since I do all my best editing with a red pen on paper. This little script did it for me.

#!/usr/bin/perl -w

use strict;
use WWW::Mechanize;

my $start = "http://www.stevemcconnell.com/cc2/cc.htm";

my $mech = WWW::Mechanize->new( autocheck => 1 );
$mech->get( $start );

my @links = $mech->find_all_links( url_regex => qr/\d+.+\.pdf$/ );

for my $link ( @links ) {
    my $url = $link->url_abs;
    my $filename = $url;
    $filename =~ s[^.+/][];

    print "Fetching $url";
    $mech->get( $url, ':content_file' => $filename );

    print "   ", -s $filename, " bytes\n";
}

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • yoink (Score:3, Informative)

    by goon (3162) on 2004.01.27 1:29 (#27769) Homepage Journal

    thanks for looking out for this. I enjoy reading bits of code complete on fridays while I'm ordering the fish and chips [geocities.com].

    having a quick look [stevemcconnell.com] (no mention of literate programming [c2.com]) it appears the c examples have been replaced with java :( - I would have been happier with cleaner examples in c.


    update no I was wrong.... cpp, vb and java examples included.

    --
    bootload [netspace.net.au], groking softwa