#!/usr/bin/perl ################################################## # COMICGET v0.2 ## # extract your favorite comic from the web ## # requires lynx, date & wget ## # Copyright 2004, 2005 Trey Hunner ## # Permission is granted to freely distribute ## # as long as this copyright notice is attached. ## # ## # This program is free software; you can ## # redistribute it and/or modify it under the ## # terms of the GNU General Public License as ## # published by the Free Software Foundation. ## # ## # This program is distributed in the hope that ## # it will be useful, but WITHOUT ANY WARRANTY; ## # without even the implied warranty of ## # MERCHANTABILITY or FITNESS FOR A PARTICULAR ## # PURPOSE. ## ################################################### $name = "dilbert"; $dir = "~/$name"; $before = "\"\"
9) { open(TEST, "$name/$year-$month-$day.jpg") or open(TEST, "$name/$year-$month-$day.gif") or push(@dates, "$year-$month-$day"); } else # Day must be two digits { open(TEST, "$name/$year-$month-0$day.jpg") or open(TEST, "$name/$year-$month-0$day.gif") or push(@dates, "$year-$month-0$day"); } close(TEST); } foreach my $day (@dates) { # Set date variables $day =~ /^(\d\d\d\d)-(\d\d)-(\d\d)/; $year = $1; $month = $2; $date = $3; print "$day\n"; # Get HTML $html_doc = `lynx -source "http://www.unitedmedia.com/comics/$name/archive/$name-$year$month$date.html"`; # Find the image location $html_doc =~ /$before(.*)$after/; if($1) {$img_loc = "http://www.unitedmedia.com/comics/$name/archive/images/$name$1";} else {print "\nError: couldn't extract filename\n"; exit;} if($1 =~ /jpg/) {$ext = "jpg";} else {$ext = "gif";} # Save the image system "wget $img_loc -O $dir/$year-$month-$date.$ext"; }