#!/usr/bin/env ruby require 'rubilicious' require 'rexml/document' # check command-line arguments if ARGV.size < 3 $stderr.puts "Usage: $0 [user] [pass] [file]" Kernel.exit 1 end # grab command-line arguments user, pass, file = ARGV # connect and add url r = Rubilicious.new(user, pass) doc = REXML::Document.new(IO::readlines(file).join) doc.root.elements.each('//body/outline') {|g| group = g.attributes['title'] puts "got group #{group}" g.elements.each('outline') {|e| title = e.attributes['title'] description = e.attributes['description'] url = e.attributes['htmlUrl'] tags = "blogroll #{group}" puts "got element #{title}: #{url}: #{description}" r.add(url, title, description, tags) # be nice to del.icio.us Kernel.sleep 1 } }