tobyaw: (Default)
Toby Atkin-Wright ([personal profile] tobyaw) wrote2009-05-01 03:03 pm

Which of your LJ friends are on DW?

Don’t know whether there is an easier way to do this. This script will read a user’s LJ friends list, and check to see whether DW accounts with the same names exist.

#!/usr/bin/ruby

require 'open-uri'

friends = Array.new

ARGV.each do |lj_user|
  open("http://www.livejournal.com/misc/fdata.bml?user=#{lj_user}").readlines.each do |line|
    friends.push line.slice(2...line.length).strip if line =~ /^<|>/
  end
end

friends.sort.uniq.each do |friend|
  puts friend if open("http://users.dreamwidth.org/#{friend}").read !~ /^<h1>Unknown User/
end