del.icio.us experiments

September 9th, 2004  |  Published in web  |  4 Comments

Maybe you’re a python programmer. Maybe you think del.icio.us is kinda cool. Maybe you’d like to be able to do this:

>>> print len(delicious.Href("https://www.vim.org/").posts())
8

or:

>>> for post in delicious.users.mattb(delicious.tags.hackney):
...   print post.description,post.href
 
Phil Gyford selling his flat https://www.gyford.com/strandbuilding/
POGO https://www.pogocafe.co.uk/
hackneycentral https://www.hackneycentral.org/
Armadillo https://www.armadillorestaurant.co.uk/

or perhaps do something much, much cooler. delicious.py is for you.

UPDATE: Since I published this code, Joshua Schachter has made the rules around use of del.icio.us APIs clearer. So that you can stay within these limits, you should be aware that no call to a method in delicious.py will cause more than one HTTP request to del.icio.us. This means that it’s left up to you to time your requests appropriately and politely, but at least you know that the code won’t spam del.icio.us of its own accord.


As with audioscrobbler a few months back, del.icio.us has been around for a while but last week really started to show up on the radar. I’ve been poking it with bits of code in the hope of achieving enlightenment.

I started by posting a few things: doing some linklogging, scripting an extraction of my items from The Daily Chump into a tag of their own, and extracting and posting pictures from my photo site under a username of their own with simple tags derived from the foaf and wordnet RDF annotations in that site’s RSS. I pointed to the picdiary experiment on the Semantic Web Interest Group IRC channel, and got some interesting discussion out of it.

The python wrapper that I used for most of this is fairly simple in structure. It uses a combination of Redland‘s RDF parsing (for the pleasantly fulsome RSS bits) and libxml2‘s HTML parser for the bits I needed to screenscrape. Href, User and Tag objects are used throughout, and can be used in combination. You can ask a User for all the posts from the user, or restrict it by passing one or more Tags into its post() method, and the converse for the Tags. It’s got some nice python automagic, creating Tag and User objects when you use syntax like “delicious.tags.foo” or “delicious.users.bar” and providing __iter__ methods that allow the “for post in delicious.tags.foo” usage.

There’s a bit of an example in the module’s __main__ code, which will take a username and find all the users that also posted two or more URLs posted by that user, and tell you what tags others used for the URLs posted by that user.

This code has evolved out of my own needs, rather than having a goal in particular. If you find it useful, I’d love to hear from you.

Responses

  1. shanti's daily links says:

    September 11th, 2004 at 10:06 am (#)

    del.icio.us experiments

    del.icio.us experiments…

  2. Leandro Siqueira says:

    October 7th, 2004 at 12:51 am (#)

    delicious.py

    Se voc

  3. Blog says:

    November 20th, 2004 at 3:38 pm (#)

    del.icio.us

    This guy’s python hacking makes “del.icio.us”:http://del.icio.us usable. It’s exciting just to see a keyword-based (rather than hierarchical) category system being used (also see “GMail”:http://gmail.google.com), but without “del.icio.us.py”:http://ww

  4. townx says:

    January 28th, 2005 at 4:10 pm (#)

    del.icio.us extensions

    Found an interesting Java API for working with del.icio.us at: http://delicious-java.sourceforge.net/.

    I’ve also been working on some Python scripts for parsing a Mozilla bo