mirror of
https://git.nolog.cz/NoLog.cz/headline.git
synced 2025-01-31 11:53:35 +01:00
Initial testing
This commit is contained in:
parent
14f863131d
commit
3274f82616
3 changed files with 50 additions and 0 deletions
12
config.yaml
Normal file
12
config.yaml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
feeds:
|
||||||
|
- name: "irozhlas.cz"
|
||||||
|
rss_source: "https://www.irozhlas.cz/rss/irozhlas"
|
||||||
|
unique_tag: "link"
|
||||||
|
|
||||||
|
- name: "idnes.cz"
|
||||||
|
rss_source: "https://servis.idnes.cz/rss.aspx?c=zpravodaj"
|
||||||
|
unique_tag: "guid"
|
||||||
|
|
||||||
|
- name: "aktualne.cz"
|
||||||
|
rss_source: "https://www.aktualne.cz/rss/"
|
||||||
|
unique_tag: "guid"
|
36
headline.py
Normal file
36
headline.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#!/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
|
||||||
|
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
feedparser
|
||||||
|
confuse
|
Loading…
Reference in a new issue