RSSFeedTime
Revision as of 20:32, 23 September 2010 by Migratebot (talk | contribs) (Created page with "<source lang="python"> import feedparser, time, random
url = "http://search.twitter.com/search.atom?q=flu"
followTime = False
# now = time.mktime(time.localtime())
lastme...")
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