Skip to content

Latest commit

 

History

History
95 lines (75 loc) · 2.55 KB

File metadata and controls

95 lines (75 loc) · 2.55 KB

Python — RSS Feed Reader

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

Install

pip install apify-client

Read feeds and iterate items

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

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

for it in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(f"[{it['pubDate']}] {it['feedTitle']}{it['title']}")
    print("  ", it["link"])

Auto-discover feeds from website homepages

run = client.actor("logiover/bulk-rss-feed-reader").call(run_input={
    "feedUrls": ["https://arstechnica.com", "https://www.theverge.com"],
    "discoverFromWebsites": True,
    "maxItemsPerFeed": 10,
})

Collect podcast episode audio URLs

run = client.actor("logiover/bulk-rss-feed-reader").call(run_input={
    "feedUrls": ["https://feeds.megaphone.fm/thedailyshow"],
    "maxItemsPerFeed": 10,
})

episodes = [
    {"title": it["title"], "audio": it["enclosureUrl"], "date": it["pubDate"]}
    for it in client.dataset(run["defaultDatasetId"]).iterate_items()
    if it.get("enclosureUrl")
]
print(episodes)

Export items to a pandas DataFrame / CSV

import pandas as pd
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("logiover/bulk-rss-feed-reader").call(run_input={
    "feedUrls": ["https://hnrss.org/frontpage"],
    "maxItemsPerFeed": 50,
})

items = list(client.dataset(run["defaultDatasetId"]).iterate_items())
df = pd.DataFrame(items)
df.to_csv("feed-items.csv", index=False)
print(df[["feedTitle", "title", "pubDate", "link"]].head())

Build a RAG document list

run = client.actor("logiover/bulk-rss-feed-reader").call(run_input={
    "feedUrls": ["https://hnrss.org/frontpage"],
    "maxResults": 500,
})
docs = [
    {
        "id": it["guid"],
        "text": it.get("contentSnippet") or it.get("content") or it["title"],
        "url": it["link"],
        "published": it["pubDate"],
    }
    for it in client.dataset(run["defaultDatasetId"]).iterate_items()
]
# → send `docs` to your vector store / summarizer

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