Skip to content

Instantly share code, notes, and snippets.

@freddyb
Created November 4, 2011 21:42
Show Gist options
  • Save freddyb/1340561 to your computer and use it in GitHub Desktop.
Save freddyb/1340561 to your computer and use it in GitHub Desktop.
grep for keywords in rss files
import feedparser
import datetime
def main(urls, keywords):
keywords = map(lambda x: x.lower(), keywords)
for url in urls:
print "Starting to parse", url
feed = feedparser.parse(url)
for item in feed['items']:
title_text = item['title_detail']['value']
link = item['link']
struct_time = item['updated_parsed']
dtime = item['updated']
summary = item['summary']
for w in keywords:
if w in str(item).lower():
print '%s:\n "%s" <%s> ' % (dtime, title_text, link)
print summary
print "-"*50
print "Finished parsing", url
print 'Done'
if __name__ == '__main__':
'''
TODO
maybe import argparse and ask for keywords and urls on commandline
'''
urls = ['http://zone-h.org/rss/defacements', 'http://data.xssed.com/xss.rss']
keywords = ['mozilla']
main(urls, keywords)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment