#!/usr/bin/env perl
use strict;
use CGI qw/param/;
use URI;
my $comic = param("c");
my $title;
my $url = "";
my $images = "";
sub get {
my ($url) = @_;
my $ua = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030525 Mozilla Firebird/0.6";
return scalar `/opt/bin/curl -s -A "$ua" "$url"`;
}
sub page {
$url = $_[0];
$_ = get($url);
die "can't get page" unless defined $_;
}
my %imgs_seen = ();
sub img {
my ($img, $tag) = @_;
return if defined $imgs_seen{$img};
$imgs_seen{$img} = 1;
$img = URI->new_abs($img, $url)->as_string;
my $a = "";
$a = " alt=\"$tag\"" if defined $tag;
$images .= "<img src=\"$img\"$a />";
}
die "no comic specified" unless defined $comic;
if ($comic eq "userfriendly") {
# UF are now doing Referer detection.
$title = "User Friendly";
page("http://www.userfriendly.org/");
/]* SRC="([^"]*)"/is or die "no match";
img($1);
} elsif ($comic eq "sluggy") {
$title = "Sluggy Freelance";
page("http://www.sluggy.com/");
while (/previous<\/a>/is or die "no match";
img("index-1.gif", $1);
} elsif ($comic eq "megatokyo") {
$title = "Megatokyo";
page("http://www.megatokyo.com/");
//is or die "no match";
img($1);
} elsif ($comic eq "helen") {
# This doesn't work.
$title = "Helen, Sweetheart of the Internet";
page("http://www.comicspage.com/comicspage/main.jsp?custid=69&catid=1242&dir=/helen");
/]* ALT="Comic for/is or die "no match";
img($1);
} elsif ($comic eq "longface") {
$title = "Why The Long Face";
page("http://www.absurdnotions.org/");
/]* ALT="Comic for/is and img($1);
} elsif ($comic eq "boxjam") {
$title = "Boxjam's Doodle";
page("http://www.boxjamsdoodle.com/");
/]* SRC="(\/comics\/[^"]+)"/is or die "no match";
img($1);
} elsif ($comic eq "sinfest") {
$title = "Sinfest";
page("http://www.sinfest.net/");
/]* SRC="(\/comics\/[^"]+)"/is or die "no match";
img($1);
} elsif ($comic eq "dilbert") {
$title = "Dilbert";
page("http://www.unitedmedia.com/comics/dilbert/index.html");
/]* ALT="Today's Dilbert Comic">/is or die "no match";
img($1);
} elsif ($comic eq "sheldon") {
$title = "Sheldon";
page("http://www.sheldoncomics.com/");
/]* ALT="Today's Comic"/is or die "no match";
img($1);
} elsif ($comic eq "nukees") {
$title = "Nukees";
page("http://www.nukees.com/");
/]* SRC="(\/comics\/[^"]+)"/is or die "no match";
img($1);
} elsif ($comic eq "gpf") {
$title = "General Protection Fault";
page("http://www.gpf-comics.com/");
/]* SRC="(\/comics\/[^"]+)"/is or die "no match";
img($1);
} elsif ($comic eq "errantstory") {
$title = "Errant Story";
page("http://www.errantstory.com/");
if (/]* SRC="(\/comics\/[^"]+)"/is) {
} else {
die "no match";
}
img($1);
} elsif ($comic eq "reallife") {
$title = "Real Life";
page("http://www.reallifecomics.com/");
/src='(\/index\.php\?do_command=show_strip[^']+)'/is or die "no match";
# Growling a bit at this, but it's more work than I'm willing to put in
# to make it possible to directly link to their image.
img("http://www.reallifecomics.com/aqua/logo.gif", $1);
} elsif ($comic eq "wapsisquare") {
$title = "Wapsi Square";
page("http://wapsisquare.com/");
/]* SRC="(\/comics\/[^"]+)"/is or die "no match";
img($1);
} elsif ($comic eq "phd") {
$title = "PhD";
page("http://www.phdcomics.com/comics/comics.php");
/$title
$url
$title$title
$url
$images
EOF