__author__ = 'Deepak Sarda'
__version__ = '1.0'
__copyright__ = '(c) 2005 Deepak Sarda'
__license__ = 'Public Domain'
__url__ = 'http://www.antrix.net/'
import urllib2, base64
from xml.dom import minidom
basedir = '.'
htmlfile = 'movie_ratings.html'
username = 'johndoe'
password = 'janedoe'
request = urllib2.Request('http://del.icio.us/api/posts/recent?tag=movies&count=5')
base64string = base64.encodestring('%s:%s' % (username, password))[:-1]
request.add_header("Authorization", "Basic %s" % base64string)
xmlFile = urllib2.urlopen(request)
xmldoc = minidom.parse(xmlFile)
xmlFile.close()
posts = xmldoc.getElementsByTagName('post')
if posts:
f = open('%s/%s' % (basedir, htmlfile), 'w')
f.write('<ul>\n')
for post in posts:
movie = post.attributes['description'].value
href = post.attributes['href'].value
rating = post.attributes['extended'].value
f.write('<li><a href="%s" title="%s rated %s">%s</a> [%s]</li>\n' %
(href, movie, rating, movie, rating))
f.write('\n</ul>\n')
f.close()