inicio mail me! sindicaci;ón

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

Related posts

  • My 1000th delicious item
  • Delicious api is (partially) broken
  • Choosing a RDBMS
  • The GET mess
  • EuroPython Day 1
  • Gravatar

    Backup your del.icio.us bookmarks « Meltin’ Posts said,

    September 24, 2006 @ 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 [...]

    RSS feed for comments on this post · TrackBack URI

    Leave a Comment