How to import your ReadItLater items into Delicious (python converter)

I like readitlater; but recently I found myself wanting to share some of my tagged items with other people and couldn’t find a way to do it. I used Delicious years ago and that’s always been a much more social app, so fired that up, and looked for way to import items.

Unfortunately the export format of readitlater isn’t compatible with the import format required by Delicious; so here’s a quick python script to convert a ReadItLater exported html file to a file that Delicious’s import will accept.

Get the export

First, visit and download that file somewhere; it should create ril_export.html

Convert to Delicious format

Copy the script below to (or whatever you feel like) then run:

./ ril_export.html converted_for_delicious.html

Import to Delicious

Then visit the Delicious import page at and point it at your generated file (converted_for_delicious.html) and hey presto, you’ve got all your readitlater bookmarks in Delicious complete with tags. Read items from RiL will have an extra tag “read” and unread items have an “unread” tag.

The script

(requires python2 and BeautifulSoup4 to be installed; you can install BeautifulSoup4 with pip)

#!/usr/bin/env python

from bs4 import BeautifulSoup
import sys
import os

def usage():
    print "r2d <inputfile> <outputfile>"
    return 1

def first_child(list):
    for item in list:
        return item

def process(ul, extraTag, output):
    for li in ul.find_all("li"):
        a = li.a
        replacements = dict()
        replacements[":tags"] = a["tags"] + "," + extraTag
        replacements[":time_added"] = a["time_added"]
        replacements[":href"] = a["href"]
        replacements[":content"] = first_child(a)
        outputString = """<DT><A HREF=":href" ADD_DATE=":time_added" PRIVATE="1" TAGS=":tags">:content</A>\n"""
        for key in replacements:
            outputString = outputString.replace(key, replacements[key])

def main():
    args = sys.argv[1:]
    if len(args) != 2:
        return usage()
    infile = args[0]
    outfile = args[1]
    if not os.path.isfile(infile):
        print "Cannot read input file:", infile
    soup = BeautifulSoup(file(infile).read())

    output = file(outfile, "w")
    output.write("""<!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">

    uls = soup.find_all("ul")
    unread = uls[0]
    read = uls[1]
    process(ul=unread, extraTag="unread", output=output)
    process(ul=read, extraTag="read", output=output)


if __name__ == "__main__":







One response to “How to import your ReadItLater items into Delicious (python converter)”

  1. […] workflow I've got used to.To get the items into Delicious, (shameless self-plug) I wrote this:… which is a python script to convert the ReadItLater export to Delicious-friendly import […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.