Ruben Laguna’s blog

Import Delicious Bookmarks Into Evernote

I tried to use the delicious online import tool from Evernote and I have to say that I’m not satisfied with it. It’s limited to 1000 tags (that’s due to important performance issues in Evernote when the number of tags is big) and if you don’t import the tags the tag information is lost.

I was expecting that it will add the delicious tags and link notes as body text in the Evernote note but they don’t. So I decided to do my own import to preserve that information.

That’s how bookmarks look like when using the online tool provided by Evernote:

My tool uses a delicious backup in Netscape Bookmarks file format created with in delicious with “Settings ⇒ Export/Backup bookmarks” as input. And uses the Mac Scripting for Evernote to create notes in a local notebook named del2 (that has to be previously created).

The delicious bookmarks looks like this once they are imported to evernote

Here is the ruby script (also as a gist) that I used to do the import (note that you need to install rubyosa on htmlentities gems prior to use:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<span class='line'>#!/usr/bin/ruby -w
</span><span class='line'>require "rubygems"
</span><span class='line'>require "rbosa"
</span><span class='line'>require "cgi"
</span><span class='line'>require "htmlentities"
</span><span class='line'>require 'iconv'
</span><span class='line'>
</span><span class='line'>
</span><span class='line'>OSA.utf8_strings = true
</span><span class='line'>evernote = OSA.app('Evernote')
</span><span class='line'>coder = HTMLEntities.new
</span><span class='line'>
</span><span class='line'>i=1
</span><span class='line'>url = nil
</span><span class='line'>add_date = nil
</span><span class='line'>title = nil
</span><span class='line'>last_visit = nil
</span><span class='line'>tags = nil
</span><span class='line'>notes = ""
</span><span class='line'>File.new("delicious-20090807.htm").each{|line|
</span><span class='line'>  #next unless i >2261
</span><span class='line'>
</span><span class='line'>  if line =~ /&lt;DT>&lt;A HREF="(.*)" LAST_VISIT="(.*)" ADD_DATE="(.*)" TAGS="(.*)">(.*)&lt;\/A>$/
</span><span class='line'>    if url
</span><span class='line'>      #puts "#{i} url:#{url} add:#{Time.at(add_date.to_i)} last:#{Time.at(last_visit.to_i)} tags:#{tags} title:#{title} notes:#{notes}"
</span><span class='line'>      #title = CGI.escapeHTML(title)
</span><span class='line'>      #notes = CGI.escapeHTML(notes)
</span><span class='line'>      #titleunencoded = Iconv.conv("UTF-8","ISO-8859-1",title)
</span><span class='line'>      titleunencoded = title[0,254]
</span><span class='line'>      title = coder.encode(title,:named)
</span><span class='line'>      notes = coder.encode(notes,:named)
</span><span class='line'>      tags = coder.encode(tags,:named)
</span><span class='line'>      body = "h1. #{title}
</span><span class='line'>      body += "p. &lt;a href=\"#{url}\">#{title}&lt;/a>
</span><span class='line'>      body += "h2. tags
</span><span class='line'>      body += "p. #{tags}
</span><span class='line'>      body += "h2. description and notes
</span><span class='line'>      body += "p. #{notes}
</span><span class='line'>      body += "h2. dates
</span><span class='line'>      body += "p. add date: #{Time.at(add_date.to_i)}
</span><span class='line'>      body += "p. last visit date: #{Time.at(last_visit.to_i)}
</span><span class='line'>      puts body
</span><span class='line'>      notehandle = evernote.create_note(:with_html => body, :title => titleunencoded, :notebook => "del2" )
</span><span class='line'>      notehandle.source_url = url
</span><span class='line'>     
</span><span class='line'>      i += 1
</span><span class='line'>      url,last_visit,add_date,tags,title,notes = nil,nil,nil,nil,nil,""
</span><span class='line'>    end
</span><span class='line'>    url,last_visit,add_date,tags,title = $1, $2, $3, $4, $5
</span><span class='line'>  else
</span><span class='line'>    notes += line unless url.nil?
</span><span class='line'>  end
</span><span class='line'>}</span>

Comments

Copyright © 2015 - Ruben Laguna - Powered by Octopress