This project is a News Sentiment Analysis tool that scrapes news articles from various sources and performs sentiment analysis on the content. It provides a user-friendly interface for selecting news sources and viewing the sentiment analysis results.
- Scrapes news articles from multiple sources (CNN, ABC News, New York Times)
- Performs sentiment analysis on news headlines and descriptions
- Provides a Gradio-based web interface for easy interaction
- Displays results in a clean, tabular format
news_sentiment_analyzer.py: Main script that orchestrates the news scraping and sentiment analysis process.rss_news_scraper.py: Contains classes for scraping RSS feeds from different news sources utilizing the Adapter Design Principal.sentiment_analyzer.py: Implements sentiment analysis using a pre-trained DistilBERT model.
- Python 3.7+
- Required libraries: gradio, pandas, beautifulsoup4, requests, transformers, tqdm, emoji
- Run the main script:
python main.py
- When you run the script, it will start a local server and provide a URL to access the UI in your web browser. Users can then select news sources and click "Submit" to see the analysis results.
- Select one or more news sources (CNN, ABC News, NYT) and click "Run" to start the analysis.
- View the sentiment analysis results in the table below.
Sample Output
The project follows a modular architecture:
- RSSNewsScraper: Scrapes news articles from RSS feeds using specific adapters for each news source.
- SentimentAnalyzer: Performs sentiment analysis on the scraped news content using a pre-trained model.
- NewsSentimentAnalyzer: Coordinates the scraping and analysis processes, and provides the user interface.
The project also comes with a basic set of core pytest files
Run the group of tests via:
pytest
or individually. For example:
pytest -vs tests/test_sentiment_analyzer.py
This also shows how you can call the modules directly instead of using the Gradio UI.
If you have any questions or feedback, please open an issue on the GitHub repository or reach out via LinkedIn

