Tracking LiveJournal "Friend of"

brian_d_foy on 2004-04-30T21:07:00

LiveJournal is pretty cool---they have 53kr33t URLs to get information so I do not have to screen scrape.

In this case, I want to see who has added a user as their friend. I store that list and when I check again, I flag the new entries.

#!/usr/bin/perl -w
use strict;

use File::Spec::Functions;

use LWP::Simple qw(get);

my $user = $ARGV[0] || $ENV{LJ_USER} || die "No user named!\n";

my $data = get( "http://www.livejournal.com/misc/fdata.bml?user=$user" );

my @friends = $data =~ m|^<\s+(\w+)$|gm;

my $Counter = $ENV{LJ_FRIENDS_DB} || catfile( $ENV{HOME}, ".lj_friends_$user" );

dbmopen my %hash, $Counter, 0640 or die $!;

my $count = 1; foreach my $friend ( @friends ) { $hash{ $friend }++; printf "%3d: %-15s", $count++, $friend; print "\t<--- NEW" if $hash{ $friend } == 1; print "\n"; }


Muuuuuch easier ...

Ovid on 2004-04-30T21:44:27

... than the way I was doing it.