| 65 | |
| 66 | |
| 67 | class Feed: |
| 68 | def __init__(self, url: str, tag: str | None = None) -> None: |
| 69 | self.feed_parse = feedparser.parse(url) |
| 70 | self.title: str = self.feed_parse.feed.title |
| 71 | self.link: str = self.feed_parse.feed.link |
| 72 | self.rss_feed: str = url |
| 73 | self.tag: str | None = tag |
| 74 | |
| 75 | def articles(self) -> List[Dict[str, str]]: |
| 76 | """list all the articles of Feed""" |
| 77 | articles = [] |
| 78 | for entry in self.feed_parse.entries: |
| 79 | article = { |
| 80 | "title": entry.title, |
| 81 | "link": entry.link, |
| 82 | "published_parsed": datetime(*entry.published_parsed[:6]), |
| 83 | } |
| 84 | articles.append(article) |
| 85 | return articles |
| 86 | |
| 87 | def __str__(self) -> str: |
| 88 | return f"{self.title} -> {self.link}" |
| 89 | |
| 90 | def __repr__(self) -> str: |
| 91 | return f"Feed({self.title})" |
no outgoing calls
no test coverage detected