This post originated from an RSS feed registered with Web Buzz
by Stuart Langridge.
Original Post: Moving to del.icio.us, part 4
Feed Title: as days pass by
Feed URL: http://feeds.feedburner.com/kryogenix
Feed Description: scratched tallies on the prison wall
And finally, we need to actually display links from del.icio.us on the front page. Fetch them from del.icio.us hourly and write out a document snippet, and then include that snippet in the page.
First, how to fetch them: a trivial Python script which uses the del.icio.us REST API to get recent posts:
import xmltramp,urllib2,cgi
def e(s):
return cgi.escape(s).replace('"','"')
authinfo = urllib2.HTTPBasicAuthHandler()
authinfo.add_password('del.icio.us API', 'http://del.icio.us',
'USERNAME','PASSWORD')
opener = urllib2.build_opener(authinfo)
urllib2.install_opener(opener)
data = urllib2.urlopen('http://del.icio.us/api/posts/recent').read()
dom = xmltramp.parse(data)
out = []
for p in dom['post':]:
try:
ext = p('extended')
except:
ext = ''
out.append('<a href="%s" title="%s">%s</a>' % \
(e(p('href')),e(ext),e(p('description'))))
fp = open('/var/www/kryogenix.org/scripts/index.curlies.cached','w')
fp.write('\n'.join(out))
fp.close()
Then throw a line in crontab to actually run it, with crontab -e: