Hotnews is a high-performance news aggregator built with FastAPI for serving web requests. It aggregates news from a curated list of RSS feeds, scores them based on title/description uniqueness (higher score means more similar articles), and presents them in a clean interface.
Tech Stack
- Web Framework: FastAPI (for fast asynchronous HTTP handling)
- Templating: Jinja2
- RSS Parsing:
feedparser - Content Extraction:
BeautifulSoup(bs4) with lxml - Scoring: scikit-learn (TF-IDF vectorization + cosine similarity)
- ORM: Tortoise ORM with aiosqlite
- Data Storage: SQLite (
db.sqlite3) - Server: Uvicorn (ASGI server)
Features
- RSS Aggregation: Fetches articles from a wide range of tech, science, and news sources (configured in
app/settings.py). - Article Scoring: Scores articles based on title and description similarity using TF-IDF vectorization and cosine similarity.
- Cleanup: Automatically removes articles older than 48 hours to keep the content fresh.
- Views: Multiple views - hottest (lowest score), coldest (highest score), newest articles.
Setup & Installation
-
Clone the repository:
git clone <repository-url> cd hotnews
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
Usage
Running the Web Server
The server will start on http://127.0.0.1:8000.
Fetching News
To populate the data with the latest news, run the fetch script:
This script will:
- Fetch entries from all configured RSS feeds.
- Clean up articles older than 48 hours.
- Calculate similarity scores for articles.
Note: Run this script periodically (e.g., via cron or a scheduler) to keep the news updated.
Routes
/- Hottest articles (most unique titles)/cold- Coldest articles (least unique titles)/new- Newest articles
Configuration
- RSS Feeds: Edit
app/settings.pyto add or remove RSS feeds in theFEEDSlist. - Headers: Update
HEADERSinapp/settings.pyfor web scraping requests.