惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
MyScale Blog
MyScale Blog
博客园_首页
G
Google Developers Blog
博客园 - 【当耐特】
美团技术团队
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Vercel News
Vercel News
小众软件
小众软件
博客园 - 司徒正美
雷峰网
雷峰网
T
Tailwind CSS Blog
V
V2EX
博客园 - 三生石上(FineUI控件)
F
Fortinet All Blogs
罗磊的独立博客
量子位
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
A
About on SuperTechFans
Hugging Face - Blog
Hugging Face - Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I run 17 RSS feeds through stdlib XML parsing every morni...
Aman Sachan · 2026-06-15 · via DEV Community

Every morning at 6am IST, a 293-line Python script grabs seventeen RSS feeds, normalizes 600+ stories through three dedupe passes, buckets them into nine categories, and lands a clean brief in my inbox before I have coffee. No feedparser, no requests, no framework — just urllib, xml.etree, and a stack of regular expressions.

The Problem With Reading The News In India

India's news ecosystem is dense, multilingual, and aggressively cross-posted. The same press release from a state ministry lands on Google News, Times of India, NDTV, India Today, Scroll, and The Wire within an hour. The same air-strike story has six headlines that differ only in the outlet's name. If you naively concatenate 17 feeds you get a wall of dupes that hides the actually-new story underneath.

I wanted one thing: a brief that tells me what's new since yesterday, with the original publisher linked where possible, sorted by recency and category. I did not want a pip install marathon for a script that fetches XML.

So I wrote daily_brief.py in the india-daily skill — pure stdlib, runs on a Zo Computer scheduled agent, and has produced 40+ consecutive morning briefs without a single dependency conflict.

Feed Layer — 17 Sources, Zero Dependencies

The feed list is the boring foundation that determines everything else. I started with seven Google News queries (India, Politics, Economy, World, Tech, Business, Defence) because Google News is the single best indexer of regional stories in real time. Then I added ten direct publisher feeds — TOI, The Hindu, Indian Express, NDTV, Hindustan Times, Moneycontrol, Deccan Herald, BBC India, The Print, Scroll, The Wire — because Google News drops stories after a few hours and the original publisher is the only durable source for a morning brief.

FEEDS = [
    ("India", "https://news.google.com/rss/search?q=India&hl=en-IN&gl=IN&ceid=IN:en"),
    ("Politics", "https://news.google.com/rss/search?q=India+politics+election+bjp+congress&hl=en-IN&gl=IN&ceid=IN:en"),
    ("Economy", "https://news.google.com/rss/search?q=India+economy+market+stock&hl=en-IN&gl=IN&ceid=IN:en"),
    ("World", "https://news.google.com/rss/search?q=India+foreign+diplomacy&hl=en-IN&gl=IN&ceid=IN:en"),
    ("Tech", "https://news.google.com/rss/search?q=India+technology+ai+startup&hl=en-IN&gl=IN&ceid=IN:en"),
    ("Business", "https://news.google.com/rss/search?q=India+business+corporate&hl=en-IN&gl=IN&ceid=IN:en"),
    ("TOI", "https://timesofindia.indiatimes.com/rssfeeds/1898055.cms"),
    ("Hindustan Times", "https://www.hindustantimes.com/rss/top-news/rssfeed.xml"),
    ("The Hindu", "https://www.thehindu.com/news/national/rss.xml"),
    ("Indian Express", "https://indianexpress.com/rss/section/india/"),
    ("NDTV", "https://ndtvnews-india-edition.rss"),
    ("Moneycontrol", "https://www.moneycontrol.com/rss/latestnews.xml"),
    ("Deccan Herald", "https://www.deccanherald.com/rssfeed/front-page-topstories"),
    ("BBC India", "https://feeds.bbci.co.uk/news/world/asia/india/rss.xml"),
    ("The Print", "https://theprint.in/feed/"),
    ("Scroll.in", "https://rss.scroll.in"),
    ("The Wire", "https://thewire.in/rss"),
]

Seventeen feeds. Not 600+. The 600+ number you saw in my last post is the raw story count after dedupe — 17 feeds feeding into a wide funnel of Google News queries pulls in 50-80 fresh stories per source before I collapse them.

The parser handles both RSS 2.0 (<item>) and Atom (<entry>) in one loop:

def parse_feed(name, url):
    ctx = ssl.create_default_context()
    ctx.check_hostname = False
    ctx.verify_mode = ssl.CERT_NONE
    try:
        req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
        with urllib.request.urlopen(req, timeout=8, context=ctx) as r:
            raw = r.read().decode('utf-8', errors='ignore')
        root = ET.fromstring(raw)
        items = root.findall('.//item') or root.findall('.//entry')
        ...

Each feed is fetched in series with an 8-second timeout. A single feed going down — Scroll.in was down for 36 hours last month — never breaks the brief. The script logs ❌ Scroll.in: failed and moves on. By the time I'm reading the brief, the brief has already been emailed.

The Three Dedupe Passes

This is the part that took the most iteration. A naive title-equality check collapses maybe 30% of dupes. The actual story count goes from 600 to ~50 only after three distinct passes.

Pass 1 — Google News URL Unwrap

Google News wraps every story in a redirect URL like:

https://news.google.com/articles/CBMiXWh0dHBzOi8vd3d3LnRoZWhpbmR1LmNvbS9pbmRpYS9uYXRpb25hbC8...

That CBMi... token is the canonical article ID. Before doing any title work, I unwrap to the real publisher URL using urllib.parse.unquote on the url= parameter, and if the URL is too long to be clickable I truncate to the article ID:

def clean_url(url):
    url = url.strip()
    if 'news.google.com' in url:
        m = re.search(r'url=([^&\s]+)', url)
        if m:
            try:
                from urllib.parse import unquote
                url = unquote(m.group(1))
            except:
                pass
    if 'news.google.com' in url and len(url) > 120:
        m = re.search(r'CBM[ij][a-zA-Z0-9_-]+', url)
        if m:
            url = 'https://news.google.com/articles/' + m.group(0)
    return url[:300]

This single function takes the brief from "wall of identical 400-character Google URLs" to "clickable publisher links."

Pass 2 — Title Normalization

After URL unwrap, every story is keyed by a normalized title — punctuation stripped, lowercased, first 150 chars only:

def title_norm(t):
    t = t.lower()
    t = re.sub(r'[^\w\s]', ' ', t)
    t = re.sub(r'\s+', ' ', t).strip()
    return t[:150]

This collapses "PM Modi inaugurates Bharat Innovates 2026 in Nice" and "Modi inaugurates Bharat Innovates 2026 in Nice, France" into the same bucket. I keep the highest-quality version of the story, ranked by a url_score() function that prefers non-Google URLs (+10), quality publishers (+5), and shorter canonical URLs.

Pass 3 — Semantic Keyword Overlap

Pass 2 misses stories that use genuinely different headlines but cover the same event. "Three Indian sailors killed in US strikes on oil tankers in Gulf" and "India issues strong protest after second attack on ship off Oman" are not the same after normalization, but they overlap heavily on keywords.

I compute a Jaccard similarity on the keyword sets (with a stopword filter of 38 common words) and merge anything above 0.6:

def text_similarity(s1, s2):
    kw1 = get_keywords(s1)
    kw2 = get_keywords(s2)
    if not kw1 or not kw2:
        return 0
    inter = len(kw1 & kw2)
    union = len(kw1 | kw2)
    return inter / union if union > 0 else 0

The 0.6 threshold was tuned against a 30-day sample. Below 0.5, you start merging unrelated stories ("Modi in France" with "Modi launches scheme"). Above 0.7, the briefs get bloated with near-duplicates again.

Categorization — Keyword Bucketing Into 9 Bins

Once dedupe lands, every story is bucketed into one of nine categories by walking a keyword trie:

cat_kw = {
    'POLITICS': ['election','vote','bjp','congress','modi','rahul','parliament','minister','cabinet',
                 'campaign','party','assembly','lok sabha','govt','government','law','bill','court',
                 'arrest','kejriwal','aap','trinamool','nda','upa'],
    'ECONOMY': ['economy','gdp','market','stock','sensex','nifty','rupee','inflation','rbi','bank',
                'loan','investment','fdi','budget','tax','gst','export','trade','currency','finance','ipo','shares'],
    'WORLD': ['china','pakistan','usa','iran','russia','ukraine','diplomacy','embassy','un ',
              'global','foreign','summit','bilateral','treaty','border','trump'],
    'BUSINESS': ['company','corporate','tata','reliance','infosys','tcs','wipro','startup','merger',
                 'acquisition','deal','revenue','profit','quarter','results','launch','product','ipo'],
    'TECH': ['ai ','tech','google','meta','apple','microsoft','startup','software','app','digital',
             'cyber','data','online','semiconductor','chip','indiaai','artificial intelligence','chatgpt','robot'],
    'DEFENCE': ['defence','military','army','navy','air force','iaf','border','ladakh','weapon',
                'missile','drone','soldier','security','terror','attack','pahalgam'],
    'SPORTS': ['cricket','ipl','football','hockey','tennis','olympics','world cup','match','score',
               'player','team','tournament','bcci'],
    'SCIENCE': ['space','isro','nasa','satellite','research','health','vaccine','disease','doctor',
                'hospital','treatment'],
}

Order matters. A story that says "Tata launches new AI semiconductor plant" gets bucketed as BUSINESS, not TECH, because BUSINESS is checked first. The order reflects how Indian readers actually segment news — a corporate event is a corporate event, even if the underlying tech is interesting.

Output — Plain Text, No HTML Email Surprises

The final report is a plain text block with a fixed-width rule, category headers, and one story per block:

========================================================================
  🇮🇳 INDIA DAILY BRIEF — Last 24 Hours
  13 Jun 2026, 01:32 AM UTC | 48 stories
========================================================================

------------------------------------------------------------------------
  🏛️ POLITICS  (8 stories)
------------------------------------------------------------------------

  ⏱ 4.5h ago
  📰 Is India really home to 1.4 billion people? It's time to count - Nikkei Asia
  🔗 News | https://news.google.com/articles/CBMiqwFBVV95cUxPOUdodXRrY2JTak5xR1ZTenFMdzBk...

Plain text means it renders correctly in Gmail's plain-text mode, in Outlook, in Apple Mail, in mutt, and on a 2009 Nokia. No <table> gymnastics, no inline CSS, no images that get blocked. The optional make_pdf.py step generates a styled PDF for archive purposes, but the email is always text.

Numbers After 40 Days

The pipeline is consistent:

Metric Average Range
Raw articles fetched 612 410-810
After Pass 1 (URL unwrap) 587 395-780
After Pass 2 (title norm) 92 60-130
After Pass 3 (semantic) 51 38-72
Feeds that failed (per day) 0.8 0-3
Total runtime 47s 31s-78s
Email size 18 KB 11-32 KB

Three feeds (Scroll.in, The Wire, Deccan Herald) fail about once a week. The brief is still complete — failure-isolation is built into the per-feed try/except.

What I Cut From The Pipeline

Three things I tried and removed:

  1. An LLM-based deduplicator. I ran GPT-4o-mini over a sample of 50 borderline stories. It cost $0.14 per brief and took 12 seconds. The Jaccard pass was 0.62 accurate; GPT-4o was 0.68. Not worth it for a 6% improvement and 50x cost.
  2. Per-article sentiment scoring. Useful in theory, distracting in practice. A "mixed" sentiment label on every economy story was noise. Cut.
  3. Translating regional-language feeds. I tried adding Aaj Tak Hindi and Dinamalar Tamil. Translation was unreliable on a free tier, and most cross-posted stories already show up in English. Cut.

What's Next

The next iteration adds:

  • Stable de-duplication across days. Right now "PM Modi speaks in Parliament" and "PM Modi's Parliament speech recap" are different stories on different days. Cross-day dedupe would surface only the new angle.
  • Per-category token budget. A politics-heavy day (Rajya Sabha polls, foreign policy visit) currently dominates the brief. Cap each category at 6-8 stories and surface "what changed in category X since yesterday."
  • Story clusters with summaries. Group the surviving 51 stories into 8-10 clusters, generate a one-line summary per cluster via the same Groq free tier, and lead with the clusters.

The full code is in /home/workspace/Skills/india-daily/daily_brief.py is 293 lines including comments, make_pdf.py is 220. MIT licensed. Fork it, change the FEEDS list, point it at your Gmail, and you have a personal morning brief by the time the kettle boils.

git clone https://github.com/AmSach/india-daily
cd india-daily
python3 Scripts/daily_brief.py

If you build a regional variant — Kerala Daily, Karnataka Daily, North-East Daily — the dedupe + categorize layers carry over unchanged. The only thing that varies is the FEEDS list and the keyword trie.