2022-05-29 20:17:03 +00:00
|
|
|
import feedparser
|
|
|
|
|
|
|
|
|
|
|
|
class FeedItem():
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Feed():
|
2022-05-29 20:25:07 +00:00
|
|
|
def __init__(self, url: str, items: list) -> None:
|
2022-05-29 20:18:12 +00:00
|
|
|
self.url = url
|
|
|
|
self.items = items
|
2022-05-29 20:17:03 +00:00
|
|
|
|
|
|
|
class RssReader():
|
|
|
|
def convert_to_FeedItem(self, item: dict) -> FeedItem:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def get_items(self, items: list) -> list:
|
2022-05-29 20:28:48 +00:00
|
|
|
list_items = []
|
|
|
|
for item in items:
|
|
|
|
list_items.append(self.convert_to_FeedItem(item))
|
|
|
|
return list_items
|
2022-05-29 20:17:03 +00:00
|
|
|
|
|
|
|
def get_feed(self, url: str) -> Feed:
|
2022-05-29 20:25:07 +00:00
|
|
|
f = feedparser.parse(url)
|
|
|
|
items = self.get_items(f.entries)
|
|
|
|
return Feed(url, items)
|