I’m starting using mybucket.co as my bookmarking solution due it simplicity, intensive and easy use of tagging and easy to use API apart other features. So my first issue is a way to import all my existing bookmarks in my browser to mybucket and I coded this ruby script that parses a html file extracting urls which are uploaded to mybucket auth by api key
require "uri" require "net/http" bookmarks_file_name = 'bookmarks.html' mybucket_api_key = '[api_key for your bucket]' class Bookmark def url @url end def url=(url) @url = url end def title @title end def title=(title) @title = title end end File.open(bookmarks_file_name, 'r') do |f| bookmarks =[] while line = f.gets singlebookmark = Bookmark.new urlmatch = line.match(/<a href="([^" titlematch="line.match(/([^" )="" ]*)?="">]*)<\/A>/) if urlmatch singlebookmark.url = urlmatch[1].to_s singlebookmark.title = titlematch[1].to_s bookmarks << singlebookmark end end bookmarks.each do |b| params = {'api_key' => mybucket_api_key, 'href' => b.url, 'source' => '', 'type' => '', } x = Net::HTTP.post_form(URI.parse('http://mybucket.co/submit'), params) puts x.body puts "Added link: #{b.url}" end puts "--Summary:--" puts "File - #{bookmarks_file_name}" puts "Number of bookmarks - #{bookmarks.count}" end