mirror of
https://git.nolog.cz/NoLog.cz/headline.git
synced 2025-01-31 11:53:35 +01:00
36 lines
700 B
Python
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
|
|
|