Fetch live Google News updates using Node.js, Express, and XML parsing — simple, scalable, and SEO-friendly.

In the digital era, staying updated with real-time information defines a website’s credibility and user engagement. News websites, blogs, and media portals thrive when they deliver fresh and dynamic content.
This article walks you through building a Google News Fetcher API using Node.js, Express, and XML to JSON conversion — a simple yet powerful setup to fetch and display live news headlines directly from Google News RSS feeds.
By the end, you’ll have a working API that can pull trending headlines in real time, ready to integrate into your own projects or client websites.
Start by creating a project folder and installing required packages.
mkdir google-news-fetcher
cd google-news-fetcher
npm init -y
npm install node-fetch xml2js expressPackages explained:
express: Lightweight server framework for Node.js.
node-fetch: Fetches RSS data from Google News.
xml2js: Converts XML to JSON for easy processing.
Create a file named server.js and add the following code:
import express from "express";
import fetch from "node-fetch";
import xml2js from "xml2js";
const app = express();
const PORT = 5000;
app.get("/news", async (req, res) => {
const topic = req.query.topic || "technology";
const url = `https://news.google.com/rss/search?q=${topic}&hl=en-US&gl=US&ceid=US:en`;
try {
const response = await fetch(url);
const xmlData = await response.text();
const parser = new xml2js.Parser();
const jsonData = await parser.parseStringPromise(xmlData);
const articles = jsonData.rss.channel[0].item.map(item => ({
title: item.title[0],
link: item.link[0],
pubDate: item.pubDate[0],
source: item.source ? item.source[0]._ : "Unknown",
}));
res.json({ topic, articles });
} catch (error) {
res.status(500).json({ message: "Error fetching news", error });
}
});
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));
✅ How it works:
Fetches Google News RSS based on a query topic (e.g., ai, technology, sports).
Converts XML to JSON.
Returns a clean JSON response ready for any frontend or CMS integration.
Create a simple index.html file to show fetched data.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Google News Fetcher</title>
</head>
<body>
<h2>Live News Headlines</h2>
<div id="news"></div>
<script>
fetch('http://localhost:5000/news?topic=technology')
.then(res => res.json())
.then(data => {
const container = document.getElementById('news');
data.articles.forEach(article => {
container.innerHTML += `
<h3><a href="${article.link}" target="_blank">${article.title}</a></h3>
<p><small>${article.pubDate}</small></p>
<hr>
`;
});
});
</script>
</body>
</html>
✅ Result:
You’ll see real-time Google News headlines for your chosen topic.
To make your fetched headlines search-engine friendly, implement the following:
Schema Markup: Use the NewsArticle or BlogPosting schema for every headline.
Meta Tags: Add descriptive <meta name="description">, og:title, and og:image tags.
Canonical URLs: Ensure every headline links back to a unique page.
Performance: Use lazy loading for images and caching for speed.
Freshness: Set a cron job to auto-refresh feeds every 30–60 minutes.
These optimizations help improve visibility in Google News and search results, boosting organic reach.
You can deploy this project easily using:
Vercel or Render (for instant Node.js hosting).
GitHub Actions (for automatic updates).
WordPress REST API or React Frontend (for seamless integration).
For advanced automation, combine your fetcher with AI summarization using OpenAI or Gemini APIs to auto-generate brief summaries for each article — making your site stand out to editors and readers alike.
You’ve just built a fully functional Google News Fetcher API that retrieves live headlines for any topic — scalable, SEO-ready, and easy to integrate.
This setup helps news websites, blogs, and dashboards maintain content freshness while improving search rankings and user engagement.
0
1
0