now there's an idea
Jan. 14th, 2004 03:11 pmThe redoubtable Dave Zuckerman writes:
I'm not a huge blog fan. Every once in a while, just to be contrarian, I think about doing periodic .plan updates, just so I can tell people who ask if I blog that they'll have to finger me to find out! Bwahahahah!
Now i'm tempted to figure a way to stick my latest LJ entry into my .plan.
Re: No problemo!
Date: 2004-01-14 08:00 pm (UTC)#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
my $content = get("http://www.livejournal.com/users/ronebofh/");
local($/);
if ($content =~ m|<div class="entry">(.*?)</div>|ms)
{
my $latest_entry = $1;
#strip tags and crap
$latest_entry =~ s/<.*?>//g;
$latest_entry =~ s/ / /g;
open PLAN, ">$ENV{HOME}/.plan" or die "can't open .plan: $!";
print PLAN $latest_entry;
close PLAN or die "can't close .plan: $!";
}
__END__
Re: No problemo!
Date: 2004-01-14 08:25 pm (UTC)It breaks as soon as he changes layout/format. Or at least has the potential to break - some layouts don't even use the div.
Splitting the RSS feed is the way to go.
my $content = get("http://livejournal.com/users/ronebofh/rss");
Then split on "", chop off everything after , de-htmlise as you do, and you're good to go. Though I'd run it through HTML::Parser to expand the entities rather than trusting to , and I'd use an XML parser anyway.
sol.
.
Re: No problemo!
Date: 2004-01-14 08:28 pm (UTC)"split on <description>", and you want the second element of the array thus produced. Then discard everything after "</description>", etc.
I can't be expected to be thinking right, I'm at work!
sol.
.