Notes:
-
Problem Solved: Extracts headlines from news websites in real time.
-
Customization Benefits: Filter by topic or sentiment, or push to dashboards.
-
Further Adoption: Use for trend analysis, sentiment detection, or alert systems.
Python Code:
import feedparser
def get_news_rss(feed_url):
feed = feedparser.parse(feed_url)
return [{'title': entry.title, 'link': entry.link} for entry in feed.entries]
rss_url = "http://feeds.bbci.co.uk/news/rss.xml"
headlines = get_news_rss(rss_url)
for news in headlines[:5]:
print(news['title'], "-", news['link'])
No comments:
Post a Comment