π― Project Objective
To build a News Aggregator Application that automatically fetches and displays the latest news headlines from multiple online sources using APIs or web scraping.
Skills Demonstrated:
- Working with APIs (
requests,json) - Parsing and structuring data
- GUI creation using
Tkinter - File handling and optional CSV export
- Error handling and API rate-limit management
π§ Project Overview
The News Aggregator App allows users to:
- Fetch top news headlines from multiple sources (e.g., BBC, CNN, TechCrunch, etc.)
- Filter news by category (Technology, Business, Sports, Entertainment)
- Display results in a clean, scrollable GUI
- Optionally save news summaries to a file for later reading
Real-Life Applications:
- Personalized news dashboard
- Daily summary emailer
- Stock/crypto news monitor
- AI summarizer or alert system backend
βοΈ Technology Stack
| Library | Purpose |
|---|---|
requests | To call news APIs |
json | Parse API responses |
tkinter | GUI development |
pandas (optional) | Export news data |
datetime | Timestamp logs |
π§© Example Code β News Aggregator (Tkinter + NewsAPI)
Note: This script auto-installs missing modules.
import os
import sys
import subprocess
# β
Auto-install missing packages
def install(package):
try:
__import__(package)
except ImportError:
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
install("requests")
install("tkinter")
import requests
import tkinter as tk
from tkinter import messagebox, scrolledtext
from datetime import datetime
# Replace with your free API key from https://newsapi.org/
API_KEY = "your_api_key_here"
def fetch_news(category="general"):
url = f"https://newsapi.org/v2/top-headlines?country=us&category={category}&apiKey={API_KEY}"
try:
response = requests.get(url)
data = response.json()
if data["status"] != "ok":
messagebox.showerror("Error", "Failed to fetch news.")
return
news_box.delete(1.0, tk.END) # Clear previous text
for article in data["articles"][:10]: # Show top 10
title = article["title"]
source = article["source"]["name"]
url = article["url"]
description = article["description"]
news_box.insert(tk.END, f"ποΈ {title}\nπ Source: {source}\nπ {url}\nπ {description}\n\n")
news_box.insert(tk.END, f"Last updated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
except Exception as e:
messagebox.showerror("Error", f"Could not retrieve news: {e}")
# GUI setup
root = tk.Tk()
root.title("π° News Aggregator App")
root.geometry("600x500")
root.config(bg="#f0f0f0")
tk.Label(root, text="Select News Category:", font=("Arial", 12, "bold"), bg="#f0f0f0").pack(pady=10)
categories = ["general", "business", "technology", "sports", "entertainment", "science", "health"]
category_var = tk.StringVar(value="general")
category_menu = tk.OptionMenu(root, category_var, *categories)
category_menu.pack()
tk.Button(root, text="Fetch News", command=lambda: fetch_news(category_var.get()),
font=("Arial", 12), bg="#2196F3", fg="white").pack(pady=10)
news_box = scrolledtext.ScrolledText(root, wrap=tk.WORD, width=70, height=20, font=("Arial", 10))
news_box.pack(padx=10, pady=10)
root.mainloop()
π§Ύ Sample Output
Category: Technology
ποΈ Google Launches New AI Model for Developers
π Source: TechCrunch
π https://techcrunch.com/ai-launch
π The new model enhances productivity and AI-based automation.
ποΈ Apple Reveals New MacBook Lineup
π Source: BBC News
π https://bbc.co.uk/macbook
π Apple introduces faster M3 chips for creative professionals.
π§ How It Works
- User selects a category (e.g., βtechnologyβ).
- App calls NewsAPI with the selected parameter.
- JSON response contains headline data.
- GUI displays the top stories with titles, sources, and URLs.
π API Setup
- Visit https://newsapi.org/
- Sign up and generate a free API key
- Replace:
API_KEY = "your_api_key_here" - Run the script β your news app goes live! π
πΎ Optional β Export Headlines
Add this snippet after fetch_news() to save results to a file:
with open("latest_news.txt", "w", encoding="utf-8") as file:
for article in data["articles"]:
file.write(f"{article['title']} - {article['source']['name']}\n")
β
You can later upgrade it to export CSV or Excel using pandas.
π§© Advanced Features to Try
- π Add language or country filter
- π Add keyword search bar
- π Auto-refresh every 15 minutes
- πΎ Save favorite articles locally
- π± Build a mobile/web version using Flask or Kivy
β Key Takeaways
- Integrating and using third-party APIs
- Parsing structured JSON data
- Building GUI interfaces for real-time content
- Managing user input and errors gracefully
- Creating professional-grade data tools
π§ Learning Outcomes
After completing this project, youβll be able to:
- Connect Python applications with live API data
- Build interactive interfaces for real-world use
- Extend your app into dashboards or personal productivity tools

Leave a Reply