The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
import feedparser, time, random
url = "http://search.twitter.com/search.atom?q=flu"
followTime = False
# now = time.mktime(time.localtime())
lastmessagetime = None
# SET THE LASTTIME BASED ON THE FEED...
feed = feedparser.parse(url)
lastmessagetime = time.mktime(feed.entries[0].updated_parsed)
while True:
print "."
time.sleep(5)
feed = feedparser.parse(url)
for e in reversed(feed.entries):
etime = time.mktime(e.updated_parsed)
if etime <= lastmessagetime:
# print "skipping message"
continue
# Reproduce the timing of the messages...
if followTime:
if lastmessagetime != None:
elapsed = (etime - lastmessagetime)
time.sleep(elapsed)
else:
time.sleep(random.randint(0,5))
print e.title.encode("utf-8")
print
lastmessagetime = etime