Skip to content

Backup delicious

Ever wondered how to backup your gazillion of website stored online with delicious?

Nothing can be more simple: delicious exposes a REST API enabling you to download your addresses in a simple XML file.

Here’s a bunch of lines to do that:

[code lang="python"] import urllib2 import time

API_URL = "https://api.del.icio.us/v1/posts/all"

USER = "XXX" PASSWD = "YYY"

manager = urllib2.HTTPPasswordMgrWithDefaultRealm() manager.add_password(None, API_URL, USER, PASSWD)

handler = urllib2.HTTPBasicAuthHandler(manager) opener = urllib2.build_opener(handler)

res = None try: res = opener.open(API_URL) except urllib2.URLError, e: if hasattr(e, 'reason'): print 'Reason: ', e.reason elif hasattr(e, 'code'): print 'Error code: ', e.code

if res: filename = "%s.xml" % "_".join(time.asctime().split()).replace(":", "-") f = open(filename, "w") f.write(res.read()) f.close() print "%s written" % filename [/code]

You can easily “tune” it to be more scripty or put it under cron/launchd/whatever handling.

Update:

Fredrik Lundh posted a way to retrieve posts from delicious using JSON: grabbing delicious posts with python

One Trackback/Pingback

  1. Backup your del.icio.us bookmarks « Meltin’ Posts on Sunday, September 24, 2006 at 10:34 am

    [...] A nice – few lines – script in Python using del.icio.us API is here: A song for the lovers » Backup delicious. Posted by savino Filed in web 2.0, geek, del.icio.us, software, python, Social Bookmarking, scripting, semantics [...]

Additional comments powered by BackType