Previous Entry Share Next Entry
Finding LiveJournal friends on
Frogmarch 2002 - Whitby
It struck me that it would be useful to be able to see if any of one’s LiveJournal friends are on, so I wrote a script to do it. Probably not very efficient, but it works.

This depends on people using the same username across different sites, however, so bear in mind that while it may identify a username on that matches one of your LJ friends, it might not be the same person.

Being Ruby, I’d imagine it works on most platforms.

#!/usr/bin/env ruby

require 'net/http'
require 'net/https'
require 'open-uri'

friends =

ARGV.each do |user|
  open("{user}").readlines.each do |line|
    friends.push line.slice(2..-1).strip if line.match /^>/

http ='', 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.start do |connection|
  friends.sort.uniq.each do |friend|
    puts friend if connection.head("/#{friend}").code.to_i.eql? 200


Log in

No account? Create an account