['rubygems', 'hpricot', 'open-uri', 'net/https', 'cgi'].each {|lib| require lib} # Netvibes bookmarks XML file file = ARGV.shift bookmarks = [] page = Hpricot(open(file)) page.search("//link").each do |link| bookmarks << { :title => link.get_attribute("title"), :description => link.get_attribute("title"), :url => link.get_attribute("url"), :tags => link.get_attribute("tags").split(', ').join(" "), :shared => "yes" } end puts "Transferring #{bookmarks.length} bookmarks to Del.icio.us" puts "Do it?"; gets # Del.icio.us target for bookmarks username = "nicwilliams" # your del.icio.us username password = "UHUst0ck" # your del.icio.us password resp = href = ""; bookmarks.each do |bookmark| begin http = Net::HTTP.new("api.del.icio.us", 443) http.use_ssl = true http.start do |http| pp bookmark req = Net::HTTP::Post.new("/v1/posts/add", {"User-Agent" => "drnicwilliams.com Netvibes to Delicious"}) req.basic_auth(username, password) req.set_form_data bookmark response = http.request(req) resp = response.body puts "#{Hpricot(resp).search('/result').first.get_attribute('code').humanize} -> #{bookmark[:title]}" end rescue SocketError raise "Host " + host + " not accessible" end end