知り合いにしか教えていなかったのですが、任意の tDiary を RSS 化するCGIを公開しています。
興味ある人のために、ソースも公開。あんまキレイじゃない。
#!/usr/local/bin/perl -w
use strict;
use Cache::FileCache;
use CGI;
use Encode::compat;
use Encode;
use LWP::Simple;
use lib "/bulknews/lib";
use RSS::Simple;
my $cache = Cache::FileCache->new({
    namespace => "tdiary2rss",
    default_expires_in => 60 * 30,
});
my $itempat = <<'PAT';
<div class="section">
<h3><a href="(.*?)"><span class="sanchor">.*?</span>
</a> *(?:\[.*?\])?(.*?)</h3>(.*?)
</div>
PAT
    ;
my $q = CGI->new;
$q->charset("UTF-8");
my $url  = $ARGV[0] || $q->path_info;
$url =~ s!^/!!;
my $html;
unless ($html = $cache->get($url)) {
    $html = get($url);
    $cache->set($url => $html);
}
$html = decode("euc-jp", $html);
my $title = ($html =~ m!<title>(.*?)</title>!i)[0];
my $rss = RSS::Simple->new();
$rss->channel(
    title => $title,
    link  => $url,
);
while ($html =~ s/$itempat//s) {
    my($link, $title, $body) = ($1, $2, $3, $4, $5, $6);
    $title =~ s/<.*?>//g;
    my @date = $link =~ /(\d{4})(\d{2})(\d{2})/;
    $rss->add_item(
        dc => { date => "$date[0]-$date[1]-$date[2]T00:00:00+09:00" },
        link => $link,
        title => $title,
        content => { encoded => $body },
    );
}
print $q->header('text/xml'), encode("UTF-8", $rss->as_string);
RSS::Simple は適当にでっち上げた、XML::RSS 代替。なんとなく XML::RSS 使いたくなかったので。
link つけました。
Posted by: miyagawa on April 21, 2004 05:21 PM