File size: 632 Bytes
42b5a1a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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[: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