A simple and clean Python application for reading RSS feeds from multiple news sources. Add your favorite news sites and fetch the latest articles with ease.
- Features
- Requirements
- Installation
- Usage
- Project Structure
- Configuration
- Error Handling
- Contributing
- License
- 📰 Add Multiple News Sources - Easily add RSS feed URLs to your collection
- 💾 Persistent Storage - URLs are saved to a file for future sessions
- 🔍 Parse RSS Feeds - Automatically extracts titles and links from RSS feeds
⚠️ Robust Error Handling - Gracefully handles network errors, invalid XML, and connection issues- 🎯 Simple CLI Interface - User-friendly command-line interface
- 📊 Clean Code Architecture - Well-structured, maintainable, and extensible codebase
- Python 3.9 or higher
- Standard library modules only (no external dependencies)
- Clone the repository:
git clone https://github.com/tohaHack/RSS_feed_reader.git
cd rss_feed_reader- Create a Python virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- No external dependencies needed! The project uses Python's standard library.
Run the application:
python rss_reader.pyDo you want to add new news site? (y/n): y
Enter RSS feed URL: https://example.com/news
✓ Added: https://example.com/news/feed
Do you want to add new news site? (y/n): n
Do you want to see news from saved URLs? (y/n): y
📰 Fetching from: https://example.com/news/feed
• Article Title One
https://example.com/article1
• Article Title Two
https://example.com/article2
✓ Successfully fetched 2 articles
rss-feed-reader/
├── rss_reader.py # Main application file
├── saved_urls.txt # Stored RSS feed URLs (auto-generated)
├── README.md # This file
└── .gitignore # Git ignore file
load_urls()
- Loads saved URLs from
saved_urls.txt - Returns a list of URL strings
- Handles file not found gracefully
save_url(url: str) -> bool
- Saves a new URL to the file
- Returns True on success, False on error
fetch_feed(url: str) -> Optional[dict]
- Fetches and parses RSS feed from the given URL
- Handles HTTP errors, connection errors, and XML parsing errors
- Returns dictionary with article titles as keys and links as values
add_news_site(urls: list[str]) -> list[str]
- Prompts user to enter a new RSS feed URL
- Validates input and prevents duplicates
- Returns updated URL list
display_news(urls: list[str]) -> None
- Fetches and displays articles from all saved URLs
- Shows article count for each source
main()
- Runs the main application loop
- Handles user interaction and menu navigation
By default, the application appends /feed to URLs. To change this, modify the constant in rss_reader.py:
FEED_SUFFIX = "/rss" # Change to your preferred suffixTo use a different filename:
URLS_FILE = Path("my_rss_feeds.txt")The application gracefully handles:
- HTTP Errors (404, 403, 500, etc.) - Displays HTTP error code
- Connection Errors - Notifies user when connection is lost
- Invalid XML - Handles malformed RSS feeds
- File I/O Errors - Manages missing or corrupted URL files
- Empty Input - Validates user input and prevents empty URLs
HTTP Error 404: https://example.com/invalid/feed
Connection Error: [Errno 11001] getaddrinfo failed
Invalid XML/Feed: https://example.com/feed
Here are some popular RSS feed URLs you can use:
- BBC News:
https://feeds.bbc.co.uk/news - CNN:
https://feeds.cnn.com/rss/cnn_topstories.rss - Reuters:
https://www.reutersagency.com/feed - TechCrunch:
https://feeds.techcrunch.com/techcrunch - The Verge:
https://www.theverge.com/rss
Potential features for future versions:
- Search functionality within articles
- Filter articles by keyword
- Remove/update stored URLs
- Async feed fetching for faster performance
- Article caching to reduce API calls
- Export articles to CSV/JSON
- Web-based GUI interface
- Logging system
- Configuration file support
This project follows PEP 8 style guidelines with:
- Type hints for all functions
- Docstrings for all functions
- Clear variable naming
- Single Responsibility Principle
Currently, no automated tests. To manually test:
# Test with valid RSS feed
python rss_reader.py
# Test with invalid URL (should handle gracefully)
# Test with empty input (should reject)
# Test duplicate URL entry (should reject)Issue: ModuleNotFoundError: No module named 'urllib'
- Solution: This is part of Python's standard library. Ensure you're using Python 3.x
Issue: FileNotFoundError: saved_urls.txt
- Solution: This is expected on first run. The file will be created when you add your first URL.
Issue: RSS feed returns no articles
- Solution: Not all RSS feeds have the standard
./channel/itemstructure. Some feeds may use different XML paths.
Contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Commit changes (
git commit -m 'Add new feature') - Push to branch (
git push origin feature/new-feature) - Open a Pull Request
Created by k3zu
This project is licensed under the MIT License - see the LICENSE file for details.
This tool is provided as-is for educational purposes. Ensure you have permission to access and parse RSS feeds from any news sources.
# 1. Run the app
python rss_reader.py
# 2. Add a news source
# Input: y
# URL: https://feeds.bbc.co.uk/news
# 3. View news
# Input: n
# Input: y
# 4. Exit
# Done!For more information, visit the RSS Specification.