Today's Mech doodad: Fetching the new Code Complete

petdance on 2004-01-27T03:21:56

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"; }


yoink

goon on 2004-01-27T06:29:23

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

having a quick look (no mention of literate programming) 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.