Automatic Article Summarization Tool: RSS to Notion with Python

Share:

📘 Building an Automatic Article Summarization Tool (RSS → Python → OpenAI → Notion)

Category: AI Lessons — Level: Beginner/Intermediate — Duration: 45–60 minutes

💡 Idea

We will create a tool that monitors any RSS, collects new links, extracts the article text, summarizes it using the OpenAI API, and then automatically saves the summary in a Notion database. You can run it manually or schedule it via Zap.

🧰 Requirements

  • An active OpenAI account with a API key.
  • A Notion workspace and a database to save the summaries.
  • Python 3.10+ installed on your machine.
  • An RSS link from a news source/blog.
  • (Optional) A Zapier account to trigger the code when a new RSS item arrives.

🔧 Step 1: Understanding RSS and Choosing a Source

RSS is a standard format for syndicating updated content (titles/summary/link). You will find the RSS link on many websites or through the orange RSS icon. We will use this link as an input for the tool.

🗂️ Step 2: Setting Up a Database in Notion

  1. Create a Database in Notion titled something like: AI Summaries.
  2. Add the following properties:
    • Title (Page Title) — Type: Title.
    • URL — Type: URL.
    • Source — Short text.
    • Summary — Long text.
    • Published — Date/Time (optional).
  3. Create an Integration from Notion Developers, grant it access to the database, and keep your NOTION_TOKEN and DATABASE_ID. Refer to the API creation documentation for more precise adjustments if needed.

🔐 Step 3: Saving Keys as Environment Variables

# macOS/Linux
export OPENAI_API_KEY="insert_key_here"
export NOTION_TOKEN="insert_notion_token"
export NOTION_DATABASE_ID="insert_database_id"

📦 Step 4: Installing Packages

pip install feedparser trafilatura requests python-dotenv

feedparser for reading RSS, trafilatura for extracting article text from HTML, and requests for sending requests to Notion.

🤖 Step 5: Complete Python Code

This code executes: Read RSS → Download Article Text → Summarize via OpenAI → Create Page in Notion.

import os, time, feedparser, requests
from datetime import datetime
import trafilaturaOPENAI_API_KEY = os.environ["OPENAI_API_KEY"]
NOTION_TOKEN = os.environ["NOTION_TOKEN"]
NOTION_DB = os.environ["NOTION_DATABASE_ID"]RSS_URL = "https://example.com/feed"  # Replace with your RSS feed# 1) Read RSS
feed = feedparser.parse(RSS_URL)
items = feed.entries[:5]  # Try the last 5 itemsdef fetch_article_text(url: str) -> str:
...

تابع القراءة

سجل دخولك مجاناً لقراءة المقال كاملاً والوصول إلى أدوات الذكاء الاصطناعي.

تسجيل الدخول / إنشاء حساب

هل كان هذا الشرح مفيداً؟