Created
March 21, 2026 14:27
-
-
Save YonLiud/aeec70a353a860cd4546de910221c5bc to your computer and use it in GitHub Desktop.
n8n Code node that parses multiple Google News RSS feeds into per-ticker title arrays, with configurable time-based filtering.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const HOURS_BACK = 12; // Hours back filter | |
| const cutoff = new Date(Date.now() - HOURS_BACK * 60 * 60 * 1000); | |
| const result = {}; | |
| for (const item of $input.all()) { | |
| const channel = item.json.rss.channel; | |
| const titleMatch = channel.title.match(/"(\w+) stock"/i); | |
| if (!titleMatch) continue; | |
| const ticker = titleMatch[1].toUpperCase(); | |
| const items = Array.isArray(channel.item) ? channel.item : [channel.item]; | |
| const titles = items | |
| .filter(i => { | |
| const pubDate = new Date(i.pubDate); | |
| return pubDate >= cutoff; | |
| }) | |
| .map(i => i.title.replace(/<[^>]*>/g, '').trim()); | |
| if (titles.length > 0) { | |
| result[ticker] = titles; | |
| } | |
| } | |
| return Object.entries(result).map(([ticker, titles]) => ({ | |
| json: { ticker, titles } | |
| })); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment