A script that scrapes the latest headlines from RSS feeds, clusters them by topic using Gemini, and writes a concise daily briefing.
feedparser reads any RSS feed — BBC, Reuters, TechCrunch, anything.
import feedparser
FEEDS = [
"http://feeds.bbci.co.uk/news/rss.xml",
"https://techcrunch.com/feed/",
"https://feeds.reuters.com/reuters/topNews",
]
headlines = []
for url in FEEDS:
feed = feedparser.parse(url)
for entry in feed.entries[:5]: # top 5 per source
headlines.append({
"title": entry.title,
"summary": getattr(entry, "summary", ""),
"source": feed.feed.title,
})
print(f"Fetched {len(headlines)} headlines")
for h in headlines[:3]:
print(f" [{h['source']}] {h['title']}")
Fetched 15 headlines [BBC News] UK inflation falls to 2.3% in April [TechCrunch] Google announces Gemini 2.0 at I/O [Reuters] Oil prices rise amid supply concerns
Ask Gemini to group related stories and write a briefing.
import google.generativeai as genai
from datetime import date
genai.configure(api_key="YOUR_GEMINI_API_KEY")
model = genai.GenerativeModel("gemini-1.5-flash")
headlines_text = "\n".join(
f"- [{h['source']}] {h['title']}: {h['summary'][:100]}"
for h in headlines
)
prompt = f"""
You are a news editor. Today is {date.today()}.
Below are today's top headlines from multiple sources.
{headlines_text}
Write a structured daily briefing with:
1. Three thematic sections (group related stories together, give each a bold heading)
2. Under each heading, 2-3 bullet points summarising the key news
3. A one-sentence "Bottom line" at the end
Be concise and objective.
"""
briefing = model.generate_content(prompt).text
print(briefing)
**Economy & Markets** • UK inflation dropped to 2.3% in April, the lowest since 2021, raising hopes of an interest rate cut. • Oil prices climbed 1.4% as OPEC+ signalled potential supply cuts heading into summer. **Technology** • Google unveiled Gemini 2.0 at I/O with major improvements to reasoning and multimodal tasks. • Apple reportedly delaying its AI features in the EU due to regulatory concerns. **World News** • Peace talks resumed in the Middle East with US envoys meeting regional leaders. **Bottom line:** Markets are cautiously optimistic on inflation while Big Tech dominates headlines ahead of the AI summer.
Write the output to a dated markdown file.
from pathlib import Path
from datetime import date
filename = f"briefing_{date.today()}.md"
Path(filename).write_text(f"# Daily Briefing — {date.today()}\n\n{briefing}", encoding="utf-8")
print(f"Saved to {filename}")
Saved to briefing_2025-08-08.md
Your AI news aggregator curates and summarises the day's news in seconds. Customise the RSS feeds for any niche — tech, finance, sport, anything.
Spotted a bug, broken code, or something that doesn't look right? Tell us what's off and we'll fix it.