I have tried for about three weeks to get zap to pull local news (Both with a NewsAPI and without-Google). Neither has succeeded. I have exhausted all my options with builds and rebuilds. Had Copilot test it to 100% accuracy (Continues to find errors each time) fixes them but still does not work. Rechecks finds another problem…. Simple request: Pull links from past 24 hours reference to Metro DC Area Fire and Police Articles and any Chick-fil-A Related Articles worldwide. Email that to my email address at 8 AM.
Why can I not get this to work? ignore the time of 3:15 (trying to get it to work)
/**
* @param {{inputData: InputData}}
*/
export default async function main({inputData}) {
const feeds = [
{
name: 'Chick-fil-A Worldwide',
url: 'https://news.google.com/rss/search?q=Chick-fil-A%20when:1d&hl=en-US&gl=US&ceid=US:en',
},
{
name: 'DC Metro Police Fire Incidents',
url: 'https://news.google.com/rss/search?q=(police%20OR%20fire%20OR%20firefighters%20OR%20shooting%20OR%20arrest%20OR%20crash)%20(%22Washington%20DC%22%20OR%20%22Fairfax%20County%22%20OR%20Arlington%20OR%20Alexandria%20OR%20%22Montgomery%20County%22%20OR%20%22Prince%20George%27s%20County%22%20OR%20%22Loudoun%20County%22)%20when:1d&hl=en-US&gl=US&ceid=US:en',
},
];
const results = [];
let totalArticles = 0;
const errors = [];
// Fetch and parse each feed
for (const feed of feeds) {
try {
const response = await fetch(feed.url);
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
const xml = await response.text();
// Extract all <item> blocks using regex
const itemRegex = /<item>[\s\S]*?<\/item>/g;
const items = [];
let match;
while ((match = itemRegex.exec(xml)) !== null) {
const itemContent = match[1];
// Extract title, link, and pubDate using regex
const titleMatch = itemContent.match(/<title>[\s\S]*?<\/title>/);
const linkMatch = itemContent.match(/<link>[\s\S]*?<\/link>/);
const pubDateMatch = itemContent.match(/<pubDate>[\s\S]*?<\/pubDate>/);
items.push({
title: titleMatch ? titleMatch[1].trim() : 'N/A',
link: linkMatch ? linkMatch[1].trim() : 'N/A',
pubDate: pubDateMatch ? pubDateMatch[1].trim() : 'N/A',
});
}
results.push({
feedName: feed.name,
articles: items,
count: items.length,
});
totalArticles += items.length;
} catch (error) {
const errorMsg = `${feed.name}: ${error.message}`;
errors.push(errorMsg);
}
}
// Build the email body from results
let body = '';
if (results.length > 0) {
body = results
.map((feed) => {
let feedBody = `\n${feed.feedName} (${feed.count} articles):\n`;
feedBody += feed.articles
.map((article) => `- ${article.title}\n Link: ${article.link}\n Published: ${article.pubDate}`)
.join('\n');
return feedBody;
})
.join('\n');
}
// Append error messages if any feeds failed
if (errors.length > 0) {
body += `\n\nErrors encountered:\n${errors.join('\n')}`;
}
// Ensure output always has subject, body, and totalArticles for email step
return {
subject: `News Digest: ${totalArticles} articles from ${results.length} feed(s)`,
body: body || 'No articles found or all feeds failed to fetch.',
totalArticles: totalArticles,
feedResults: results,
errors: errors,
};
}

