So with the help of BeautifulSoup I simply parsed the exported html and used pydelicious to post it back into delicious. Like So:
from BeautifulSoup import BeautifulSoup
import pydelicious
from itertools import count
def main():
soup = BeautifulSoup(file("export.htm").read())
user = "user"
password = "pass"
items = soup.findAll("a")
print len(items)
for item, n in zip(items, count()):
href = item["href"]
tags = item["tags"]
title = item.string
add_date = item["add_date"]
last_modified = item["last_modified"]
print n,
try:
pydelicious.add(user, password, href, title, tags=tags, dt=add_date, replace="yes")
except Exception, e:
print e
Ah, I love Python.
While writing this post I ran into some del.icio.us experiments, which might be useful to someone. And a follow-up with very pretty graphs.
1 comment:
Hi! I know this is an old post, but just a note: we fixed the import & export functions on del.icio.us so you should be able to transfer your bookmarks now without having to do all this. (We're sorry it was a little broken there for a while.)
Post a Comment