Created
December 30, 2010 16:16
-
-
Save harryf/759943 to your computer and use it in GitHub Desktop.
Puts whatever it finds in the feed in elastic search
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
#!/usr/bin/env python | |
import httplib, hashlib, json | |
import feedparser | |
def index_event(e): | |
""" Pass the event to ElasticSearch for indexing """ | |
id = hashlib.md5(e.link).hexdigest() | |
body = json.dumps({'title': e.title, 'updated': e.updated, | |
'summary': e.summary, 'link': e.link}) | |
connection = httplib.HTTPConnection('127.0.0.1:9200') | |
connection.request('PUT', '/techup/events/' + id, body) | |
def get_events(feed): | |
""" Parse the techup RSS feed """ | |
events = feedparser.parse(feed) | |
for event in events.entries: | |
index_event(event) | |
if __name__ == '__main__': | |
get_events('http://rss.techup.ch/new-techup-events') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment