Skip to content

Instantly share code, notes, and snippets.

@matthewrobertbell
Created December 24, 2011 12:47
Show Gist options
  • Save matthewrobertbell/1517279 to your computer and use it in GitHub Desktop.
Save matthewrobertbell/1517279 to your computer and use it in GitHub Desktop.
Reddit Frontpage Monitor
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