Spaces:
Sleeping
Sleeping
File size: 688 Bytes
42b5a1a b309d1d 42b5a1a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import feedparser
from newspaper import Article
def fetch_articles(rss_urls, limit=3):
articles = []
for url in rss_urls:
feed = feedparser.parse(url)
for entry in feed.entries[:1]: # limit to 1 or 2 max for entry in feed.entries[:limit]:
try:
article = Article(entry.link)
article.download()
article.parse()
articles.append({
"title": entry.title,
"link": entry.link,
"text": article.text,
"published": entry.published
})
except:
continue
return articles
|