google-news-decoder

n8n node to decode Google News URLs

Package Information

Downloads: 0 weeklyย /ย 9 monthly
Latest Version: 0.1.0

Documentation

๐Ÿ”“ n8n-nodes-google-news-decoder

A powerful n8n custom node that decodes Google News encoded URLs into clean, original article links with built-in caching and advanced configuration options.

npm version
n8n
License: MIT


๐Ÿ“‹ Table of Contents


๐ŸŽฏ Overview

This package provides a custom n8n node that transforms complex Google News RSS encoded URLs into clean, decoded URLs with intelligent caching and customizable decoding parameters.

Before:

https://news.google.com/rss/articles/CBMihAFBVV95cUxNRnMtZDFfUTgx...

After:

https://original-news-site.com/article-title-here

โœจ Features

  • ๐Ÿ”— URL Decoding - Converts Google News encoded RSS links to original URLs
  • ๐Ÿ’พ Smart Caching - Built-in LRU cache (max 1000 items) with configurable TTL
  • ๐Ÿ“Š Metadata Extraction - Retrieves signature, timestamp, and GUID
  • ๐ŸŽ›๏ธ Customizable - Configure RPC headers, locales, and endpoints
  • ๐Ÿš€ Simple Integration - Works seamlessly with n8n workflows
  • ๐ŸŽฏ RSS Optimized - Perfect for Google News RSS โ†’ article extraction pipelines
  • โšก Performance - Sequential processing with error handling and cache support

Output Data

Each decoded URL returns:

{
  "guid": "CBMihAFBVV95cUxNRnMtZDFfUTgx...",
  "encodedUrl": "https://news.google.com/rss/articles/...",
  "decodedUrl": "https://original-news-site.com/article",
  "timestamp": "1705334400",
  "signature": "CBMiXWh0dHBz...",
  "cached": false,
  "cacheAge": "0s" // Only present if cached=true
}

๐Ÿ“ฆ Prerequisites

Requirement Version
Node.js 18.x or 20.x
npm 8.x or higher
n8n 1.12+
OS Windows, Linux, macOS

๐Ÿš€ Installation

Step 1: Install n8n (if needed)

# Install n8n globally
npm install -g n8n

# Start n8n
n8n start

Step 2: Install the Custom Node

Navigate to your n8n configuration folder:

# Windows (typically)
cd C:\Users\<username>\.n8n

# macOS/Linux (typically)
cd ~/.n8n

Create the nodes directory (if not present) and initialize a new Node.js project:

mkdir -p nodes
cd nodes
npm init -y

Install the package:

Option A: From Local Path

npm install /path/to/n8n-nodes-google-news-decoder

Option B: From GitHub

npm install git+https://github.com/ziedkefidev-cell/n8n-nodes-google-news-decoder.git

Option C: From npm (if published)

npm install n8n-nodes-google-news-decoder

Step 3: Restart n8n

n8n start

๐ŸŽ‰ The node will now appear in n8n under the name "Google News Decoder"


โš™๏ธ Configuration

Basic Configuration

Parameter Type Required Description
Encoded URL String Yes Google News encoded URL to decode

Advanced Options

๐Ÿ”ง HTML Extraction

Parameter Type Default Description
Signature Attribute String data-n-a-sg HTML attribute for signature
Timestamp Attribute String data-n-a-ts HTML attribute for timestamp

๐ŸŒ Localization

Parameter Type Default Description
Locale String US:en Locale for decode request (e.g., FR:fr)

๐Ÿ”Œ API Configuration

Parameter Type Default Description
Decode Endpoint String https://news.google.com/_/DotsSplashUi/data/batchexecute Google's internal decoding endpoint
RPC Header Base JSON ["X", "X", 1, [1, 1, 1], ...] Custom RPC header structure

๐Ÿ’พ Caching

Parameter Type Default Description
Enable Cache Boolean true Enable/disable result caching
Cache TTL (minutes) Number 5 Cache time-to-live (shown when enabled)

Cache Features:

  • LRU eviction (max 1000 items)
  • Per-URL caching
  • Cached responses include cacheAge field
  • Automatic TTL expiration

๐ŸŒ HTTP Headers

Header Name Default Value Description
User-Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) ... Browser user agent
Referer https://www.google.com/ HTTP referer header

Additional custom headers can be added as needed.


๐Ÿ’ก Usage

Basic Example

  1. Add Google News Decoder node to your workflow
  2. Configure the Encoded URL field with a Google News link
  3. Execute the workflow

Input:

https://news.google.com/rss/articles/CBMiXWh0dHBzOi8vd3d3...

Output:

{
  "guid": "CBMiXWh0dHBzOi8vd3d3...",
  "encodedUrl": "https://news.google.com/rss/articles/CBMi...",
  "decodedUrl": "https://techcrunch.com/2024/01/15/ai-story",
  "timestamp": "1705334400",
  "signature": "CBMiXWh0dHBz...",
  "cached": false
}

With Caching Enabled

First Request:

{
  "decodedUrl": "https://example.com/article",
  "cached": false
}

Subsequent Request (within TTL):

{
  "decodedUrl": "https://example.com/article",
  "cached": true,
  "cacheAge": "45s"
}

๐Ÿ”„ Example Workflow

graph LR
    A[RSS Feed Node] -->|encoded URLs| B[Google News Decoder]
    B -->|clean URLs| C[HTTP Request Node]
    C -->|article content| D[Process/Store]

    style B fill:#4285F4,color:#fff

Workflow Steps:

  1. RSS Feed Node - Fetches Google News RSS feed with encoded links
  2. Google News Decoder Node - Decodes URLs to original article links (with caching)
  3. HTTP Request Node - Fetches the actual article content
  4. Processing Node - Parse, store, or analyze the article data

Example Workflow JSON

{
  "nodes": [
    {
      "name": "RSS Feed",
      "type": "n8n-nodes-base.rssFeedRead",
      "parameters": {
        "url": "https://news.google.com/rss/search?q=technology"
      }
    },
    {
      "name": "Google News Decoder",
      "type": "n8n-nodes-google-news-decoder.googleNewsDecoder",
      "parameters": {
        "encodedUrl": "={{ $json.link }}",
        "advanced": {
          "enableCache": true,
          "cacheTTL": 10
        }
      }
    },
    {
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "parameters": {
        "url": "={{ $json.decodedUrl }}"
      }
    }
  ]
}

๐Ÿš€ Advanced Features

Custom RPC Header Base

If Google changes their API structure, you can update the RPC header base:

["X", "X", 1, [1, 1, 1], 1, 1, null, 0, 0, null, 0]

Format: Must be a valid JSON array matching Google's expected structure.

Custom Locale Configuration

For international Google News sources:

Locale Description
US:en United States (English)
FR:fr France (French)
DE:de Germany (German)
JP:ja Japan (Japanese)
UK:en United Kingdom (English)

Cache Management

How the cache works:

  1. LRU Eviction: When cache reaches 1000 items, oldest entries are removed
  2. TTL Expiration: Cached results expire after configured minutes
  3. Per-URL Keying: Each unique encoded URL has its own cache entry
  4. In-Memory: Cache is lost on n8n restart (session-based)

Best Practices:

  • Enable cache for workflows processing the same URLs repeatedly
  • Use shorter TTL (1-5 min) for frequently updated news
  • Use longer TTL (30-60 min) for stable article lists
  • Disable cache for one-time bulk processing

๐Ÿ› ๏ธ Development

Clone and Setup

# Clone the repository
git clone https://github.com/<your-username>/n8n-nodes-google-news-decoder.git

# Navigate to directory
cd n8n-nodes-google-news-decoder

# Install dependencies
npm install

# Build the project
npm run build

Build Commands

# Development build
npm run build

# Watch mode (auto-rebuild on changes)
npm run dev

# Clean build artifacts
npm run clean

# Local test (without n8n)
npm run test:local

Implementation Highlights

Core Features:

  • โœ… Sequential item processing with error handling
  • โœ… In-memory LRU cache with TTL
  • โœ… Regex escaping for HTML attribute extraction
  • โœ… Flexible article ID extraction from URL
  • โœ… Configurable RPC header structure
  • โœ… Custom HTTP headers support
  • โœ… Continue-on-fail support

๐Ÿงช Testing

Local HTTP Test (without n8n)

Run a standalone test to verify the decoder works:

# Install test dependencies
npm install node-fetch

# Build the project
npm run build

# Run local test
npm run test:local

Expected Output:

๐Ÿงช Testing Google News Decoder (Local Mode)
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

Input URL:  https://news.google.com/rss/articles/CBMi...
Decoded URL: https://techcrunch.com/2024/01/15/ai-article
GUID:       CBMiXWh0dHBz...
Timestamp:  1705334400

โœ… Decode successful!

Testing in n8n

  1. Create a new workflow
  2. Add a Manual Trigger node
  3. Add Google News Decoder node
  4. Configure with test URL:
    https://news.google.com/rss/articles/CBMiXWh0dHBzOi8vd3d3LnRlY2hjcnVuY2guY29tLzIwMjQvMDEvMTUvYWktc3Rvcnkv0gEA
    
  5. Execute and check output

Test Cache Behavior

  1. Execute workflow with cache enabled
  2. Check output: "cached": false
  3. Execute again within TTL
  4. Check output: "cached": true, "cacheAge": "15s"

๐Ÿ”ง Troubleshooting

Node Not Appearing in n8n

Problem: Node doesn't show up in the n8n interface

Solutions:

  1. Verify installation in ~/.n8n/nodes/node_modules/
    ls ~/.n8n/nodes/node_modules/n8n-nodes-google-news-decoder
    
  2. Check package.json has correct n8n configuration
  3. Restart n8n completely
    pkill -f n8n
    n8n start
    
  4. Check n8n logs for errors
    n8n start --loglevel debug
    

Decoding Errors

Issue: "Could not extract decoding keys from Google News page"

Causes & Solutions:

  • โŒ Google changed HTML structure
    • โœ… Update Signature Attribute and Timestamp Attribute in Advanced options
    • โœ… Inspect a Google News page to find new attribute names
  • โŒ Invalid encoded URL
    • โœ… Ensure URL starts with https://news.google.com/
    • โœ… URL must contain /articles/ path

Issue: "Invalid decode response format"

Causes & Solutions:

  • โŒ Google changed API response structure
    • โœ… Update RPC Header Base in Advanced options
    • โœ… Check Google's current API format
  • โŒ Network timeout
    • โœ… Check internet connection
    • โœ… Verify firewall allows requests to news.google.com

Issue: "Could not extract article ID"

Causes & Solutions:

  • โŒ Non-standard URL format
    • โœ… URL must match pattern: /articles/[ARTICLE_ID]
    • โœ… ARTICLE_ID typically starts with CB

Cache Issues

Issue: Cache not working / Always returns "cached": false

Solutions:

  1. Verify Enable Cache is set to true in Advanced options
  2. Check Cache TTL is greater than 0
  3. Ensure you're using the exact same encoded URL
  4. Remember cache is lost on n8n restart

Issue: Want to clear cache

Solution:

  • Restart n8n (cache is in-memory only)
  • Or disable and re-enable cache in node settings

Build Errors

Problem: npm run build fails

Solutions:

# Clean and rebuild
rm -rf dist node_modules package-lock.json
npm install
npm run build

# If TypeScript errors persist
npm install --save-dev typescript@latest
npm run build

โš ๏ธ Important Notes

  • ๐Ÿ”„ This node relies on Google's internal URL structure and decoding endpoint
  • โšก Google may change their URL format or API at any time
  • ๐Ÿ”’ No API key or authentication required (uses public endpoints)
  • ๐Ÿ’พ Cache is in-memory and cleared on n8n restart
  • ๐Ÿ“Š Maximum 1000 cached items (LRU eviction)
  • ๐ŸŒ Works with all Google News country domains
  • โš–๏ธ Not affiliated with or endorsed by Google

Rate Limiting

While the node itself has no rate limits, Google may rate-limit requests. Recommendations:

  • Use caching to reduce API calls
  • Add delay between batches (use n8n's Wait node)
  • Process items in smaller batches

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Contribution Ideas

  • ๐ŸŒ Add proxy feature
  • ๐Ÿ”„ Batch processing optimization

๐Ÿ“ฌ Support

If you encounter any issues or have questions:


๐Ÿ™ Acknowledgments

  • Built for the n8n workflow automation platform
  • Inspired by the need for clean, trackable news URLs
  • Thanks to the n8n community for feedback and testing

Made with โค๏ธ for the n8n community

โญ Star this repository if you find it helpful!

Discussion