import urllib2, time
feeds={}
last={}
feeds['Slashdot']="http://rss.slashdot.org/Slashdot/slashdot";
feeds['Engadget']="http://www.engadget.com/rss.xml";
feeds['CNN Top']="http://rss.cnn.com/rss/cnn_topstories.rss";
feeds['CNN Tech']="http://rss.cnn.com/rss/cnn_tech.rss";
feeds['del.icio.us']="http://del.icio.us/rss/jblebrun";
feeds['BoingBoing']="http://feeds.feedburner.com/boingboing/iBag";
feeds['Scripting']="http://www.scripting.com/rss.xml";
if __name__=="__main__":
for item in feeds:
last[item]=""
while(1):
for item in feeds:
now=time.localtime()
filetime=time.strftime("%Y-%m-%d_%H:%M:%S",now)
httptime=time.strftime("%a, %d %b %Y %H:%M:%S %Z",now)
filename="%s-%s"%(filetime,item)
req=urllib2.Request(feeds[item],data=None,headers={"If-Modified-Since":last[item]})
try:
response=urllib2.urlopen(req)
last[item]=httptime
except urllib2.URLError, e:
print e
time.sleep(10)