Skip to content

Latest commit

 

History

History
85 lines (67 loc) · 2.43 KB

javascript.md

File metadata and controls

85 lines (67 loc) · 2.43 KB

JavaScript / Node.js — RSS Feed Reader

Call the RSS Feed Reader from JavaScript with the official apify-client. These snippets invoke the hosted Actor — no Actor source code is included in this repo.

Install

npm install apify-client

Read feeds and iterate items

import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });

const run = await client.actor('logiover/bulk-rss-feed-reader').call({
    feedUrls: [
        'https://hnrss.org/frontpage',
        'https://www.theverge.com/rss/index.xml',
        'https://techcrunch.com/feed/',
    ],
    maxItemsPerFeed: 25,
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();

for (const it of items) {
    console.log(`[${it.pubDate}] ${it.feedTitle} — ${it.title}`);
    console.log(`   ${it.link}`);
}

Auto-discover feeds from website homepages

const run = await client.actor('logiover/bulk-rss-feed-reader').call({
    feedUrls: ['https://arstechnica.com', 'https://www.theverge.com'],
    discoverFromWebsites: true,
    maxItemsPerFeed: 10,
});

Collect podcast episode audio URLs

const run = await client.actor('logiover/bulk-rss-feed-reader').call({
    feedUrls: ['https://feeds.megaphone.fm/thedailyshow'],
    maxItemsPerFeed: 10,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
const episodes = items
    .filter((it) => it.enclosureUrl)
    .map((it) => ({ title: it.title, audio: it.enclosureUrl, date: it.pubDate }));
console.log(episodes);

Feed a RAG / news pipeline (only new items each run)

// Schedule this Actor; GUID de-dupe means each dataset holds only fresh items.
const run = await client.actor('logiover/bulk-rss-feed-reader').call({
    feedUrls: ['https://hnrss.org/frontpage'],
    maxResults: 500,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
const docs = items.map((it) => ({
    id: it.guid,
    text: it.contentSnippet || it.content || it.title,
    url: it.link,
    published: it.pubDate,
}));
// → send `docs` to your vector store / summarizer

CommonJS variant

const { ApifyClient } = require('apify-client');
const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
// ...same as above

▶️ Actor page: https://apify.com/logiover/bulk-rss-feed-reader