from odoo import http
import feedparser
class NewsController(http.Controller):
@http.route('/rss-news', type='json', auth='public')
def rss_news(self):
feeds = [
'http://feeds.bbci.co.uk/news/rss.xml',
'https://www.reutersagency.com/feed/?best-topics=top-news',
'https://rss.cnn.com/rss/edition.rss'
]
articles = []
for feed_url in feeds:
try:
feed = feedparser.parse(feed_url)
for entry in feed.entries[:2]: # get top 2 articles from each feed
articles.append({'title': entry.title, 'url': entry.link})
except Exception:
continue
return articles[:6] # return top 6 articles total
yayaNEWS