#! /usr/bin/env perl BEGIN{$^W=1} use strict; use Data::Dumper; use File::Basename; use LWP::Simple; use HTML::Entities; ############################################# # Load the main page, parse posts ############################################# # Idiots don't implement etag or last-modified, so we have to eat up 70k every time my $main_page = get('http://www.kottke.org/index.html') or die "Unable to fetch kottke main page.\n\t"; print "Fetched bytes ", length($main_page), " from kottke\n"; my @stories; while ($main_page =~ m#
\s*

(.*?)

\s*(.*?)
#gis) { my $story = {}; my ($link, $title, $body) = ($1, $2, $3); $body =~ s#src="/#src="http://www.kottke.org/#gi; $story->{link} = $link; $story->{title} = HTML::Entities::encode_entities($title); $story->{description} = HTML::Entities::encode_entities($body); push(@stories, $story); } ############################################# # Output RSS file ############################################# my $zero_dir = dirname $0; open RSS, ">$zero_dir/kottke.rss" or die "Unable to write to kottke.rss: $!"; print RSS <<"EOF"; Newcum's Kottke Feed http://www.kottke.org/index.html David Newcum's RSS Feed of kottke.org. Contact rss_feeds\@paperlined.org for change requests. en-us EOF foreach my $story (@stories) { print RSS <<"EOF"; $story->{title} $story->{link} $story->{description} EOF } print RSS "\n";