#!/usr/bin/perl -w use strict; # Make an RSS feed for http://shlang.com/ # Written by Stanislav Shalunov, December 2007 use XML::RSS; my $base_url = 'http://shlang.com/'; undef $/; open(INDEX, 'index.html') or die; my $html = ; my @links = $html =~ m|<\s*a\s[^>]*href=["'](\S+?)["'][^>]*>\s*(.+?)\s*<\s*/\s*a\s*>|ismg; my $rss = XML::RSS->new(); $rss->channel( title => 'Hacking Startups', link => $base_url, ); for (my $i = 0; $i < @links; $i += 2) { my ($url, $title) = ($links[$i], $links[$i+1]); next if $url =~ /^((ht|f)tps?|mailto):/; last if $url eq 'writing/who-reads-this.html'; $title =~ s/\s+/ /g; my $file = $url; if ($file =~ m|/$|) { $file .= 'index.php' if -r $file . 'index.php'; $file .= 'index.html' if -r $file . 'index.html'; } $file = "/usr/local/bin/php $file|" if $file =~ m|\.php$|; open(HTML, $file) or next; my $html = ; $html =~ s|||imsg; $html =~ s|^.*?(.*?by Stanislav Shalunov)?||ims; $html =~ s|^.*20\d\d(-\d\d(-\d\d)?)?||im; $html =~ s|

Comments

.*$||ims; $rss->add_item(title => $title, link => $base_url . $url, dc => {creator => "Stanislav Shalunov"}, description => $html); } $rss->save("index.rss");