
Build a Python batch process to automatically collect AI news from RSS, remove duplicates, and summarize it
- Python
- RSS
- AI
- Automation
- SQLite
This time, we will create a Python batch process that regularly retrieves articles from RSS, removes duplicates using SQLite, and summarizes them in Japanese with a local LLM.
In conclusion, combining RSS retrieval, duplicate detection, summarization, and storage in a single script results in fewer dependencies and a structure that is easy to run with cron or a task scheduler. Since Ollama, which runs locally, is used for summarization, you can try it without sending the article bodies to an external API.
Configuration and preparation
The processing flow from RSS retrieval to duplicate detection, summarization, and SQLite storage is as follows:
The configuration for this project is as follows:
- RSS retrieval: feedparser
- Duplicate removal and storage: SQLite
- Summarization: Ollama HTTP API
- Execution: Python command and, if necessary, cron
First, install the Python packages:
On Windows, activate the virtual environment as follows:
Start Ollama and prepare the model to use for summarization. Change the model to suit your environment.
Fetch RSS and save it to SQLite
Below is the main batch script. The RSS URLs are examples, so change them to the feeds you actually want to subscribe to.
Deduplication approach
Both the URL and the title are used for duplicate detection.
When the same article is distributed through multiple RSS feeds, the URLs will usually match. However, tracking parameters and URLs may differ depending on the publisher, so title_key, which is created by removing punctuation and whitespace from the title, is also compared.
For example, titles such as the following are more likely to be considered identical:
However, separate articles may also be merged if their titles are merely similar. In actual operation, adjustments are needed, such as including the publisher name, comparing publication dates, and introducing a similarity calculation.
In this implementation, we first used simple rules that make misclassifications easy to spot. Another benefit is that the SQLite tables can be inspected directly, making it easier to improve the detection logic later.
Summarizing with a local LLM
Ollama is accessed over HTTP without using the Python SDK. This makes it easy to swap out the summarization component.
For example, if you want to use a different local model, you can specify it as follows:
In Windows PowerShell, use the following format:
Only the portion of the article body included in the RSS summary or description is used. Since the article body may be short depending on the RSS feed, if you want to improve summary quality, add a process that fetches the HTML at the URL and extracts the article body.
However, the HTML structure differs from site to site, and robots.txt and the terms of use must also be taken into consideration. It is safer to begin operations using only the information included in the RSS feed.
Checking execution results and running on a schedule
Run it for the first time.
The data is saved in ai_news.db in the same directory. To check the saved contents, run the following in the SQLite CLI.
From the second run onward, URLs or titles that have already been saved are ignored. Therefore, even if you fetch the RSS feed every day, the number of previously read articles will not keep increasing.
To run it every morning at 8:00 a.m. on Linux, add the following to cron.
I fetched the same RSS feed multiple times locally and confirmed that articles were added only on the first run, while the number added on the second run was zero. I also confirmed that when Ollama is stopped, the article is saved as a summary failure, so even the RSS fetch results are not lost.
Summary
The process of collecting AI news from RSS is easier to implement when divided into the following four steps:
- Fetch the RSS feed with feedparser
- Detect duplicates using the URL and normalized title
- Save the articles and summaries in SQLite
- Summarize them using an LLM such as Ollama
Rather than building a full-featured news platform from the start, it is recommended to start small with RSS and SQLite. Once the number of articles grows, you can add per-outlet weighting, summary reruns, keyword classification, and output to Markdown or email, expanding the system to suit your needs.


