Thursday, May 8, 2025

Web Scraping and Data Extraction - Real-Time News Extractor

 


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

IoT (Internet of Things) Automation - Smart Energy Usage Tracker

  Notes: Problem Solved: Logs and analyzes power usage from smart meters. Customization Benefits: Track per-device energy and set ale...