#!/usr/bin/python import pickle import unicodedata from sys import exit from time import strftime from urllib2 import urlopen from xml.etree.ElementTree import parse print "Content-Type: text/html\n" rss = urlopen('http://share.xmarks.com/folder/rss/uCaDgymbpz') btree = parse(rss) bookmarks = list(list(btree._root)[0]) itemElements = list(btree._root)[0].findall("item") items = {} thisdesc = "" thislink = None thistitle = None for item in itemElements: for child in list(item): if(child.tag == "link"): thislink = child.text if(child.tag == "title"): thistitle = child.text if(child.tag == "description"): thisdesc = child.text items[thislink] = {"title" : thistitle, "desc" : thisdesc[5:]} curlinks = items.keys() loadtime = strftime("%w%H") print loadtime if("021" == loadtime): print loadtime ref = open('/home/tscddb/TenSen/sandbox/xmarks/xmarks-ref', 'w') pickle.dump(curlinks,ref) ref.close() exit() ref = open('/home/tscddb/TenSen/sandbox/xmarks/xmarks-ref', 'r') reflinks = pickle.load(ref) newmarks = {} for link in curlinks: if(link not in reflinks): newmarks[link] = items[link] out = open(('/home/tscddb/tensen.net/templates/includes/xmarks.html'), 'w+') newlinks = newmarks.keys() lennewlinks = len(newlinks) parity = ["even", "odd"] outstr = "\n" if(0 == len(newlinks)): outstr = "" + \ "Dakota" + \ " has nothing new to show you today." outstr = unicodedata.normalize('NFKD', (unicode)(outstr)).encode('ascii', 'ignore') print outstr out.write(outstr) out.close()