headline/headline.py
2022-07-08 20:07:26 +02:00

36 lines
700 B
Python

#!/usr/bin/python3
import feedparser
import confuse
from pprint import pprint
config = confuse.Configuration('headline', __name__)
config.set_file('config.yaml')
for feed in config['feeds']:
rss_source = str(feed['rss_source'])
unique_tag = str(feed['unique_tag'])
name = str(feed['name'])
rss = feedparser.parse(rss_source)
for item in rss['entries']:
rss_id = item[unique_tag]
title = item['title']
description = item['description']
published = item['published_parsed']
link = item['link']
article = {
'rss_id' : rss_id,
'title' : title,
'description': description,
'published' : published,
'link' : link,
'medium' : name
}
pprint(article)
break