Created
December 24, 2011 12:47
-
-
Save matthewrobertbell/1517279 to your computer and use it in GitHub Desktop.
Reddit Frontpage Monitor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import web | |
import time | |
seen = set() | |
while True: | |
page = web.grab('http://www.reddit.com') | |
if page: | |
threads = set(page.xpath('//p[@class="title"]/a/@href||//p[@class="title"]/a/text()')) | |
new_threads = threads - seen | |
seen |= threads | |
for url, title in new_threads: | |
print u'New thread - {title} - {url}'.format(title=title, url=url) | |
time.sleep(30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment