- Introduction
- Project Structure
- Installation
- Configuration
- Running the Project
- Management Commands
- API Endpoints
- Tasks
- Models
- Utilities
- Logging
The News Aggregator project is a Django-based application that fetches news articles from an RSS feed, matches them with trending topics from Google Trends, and enriches the news articles with sentiment scores using OpenAI's GPT-3.5-turbo model. The application supports translation of trends into Ukrainian language.
news_aggregator_project/
├── news_aggregator/
│ ├── migrations/
│ ├── init.py
│ ├── admin.py
│ ├── apps.py
│ ├── models.py
│ ├── tasks.py
│ ├── tests.py
│ ├── utils.py
│ ├── views.py
│ └── management/
│ └── commands/
│ ├── clear_news.py
│ └── init.py
├── news_aggregator_project/
│ ├── init.py
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── manage.py
└── requirements.txt
-
Clone the repository:
git clone https://github.com/LIcsq/News-Parser.git cd news_aggregator_project
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Apply the migrations:
python manage.py makemigrations python manage.py migrate
- API Keys:
- Set your OpenAI API key in
settings.py
:OPENAI_API_KEY = 'your_openai_api_key'
- Set your OpenAI API key in
-
Start the development server:
python manage.py runserver
-
Start the Celery worker:
celery -A news_aggregator_project worker --loglevel=info
Custom command to delete all news entries:
python manage.py clear_news
URL: /api/news/
Method: GET
Response: JSON list of news articles with title, link, published date, and sentiment score.
Location: news_aggregator/tasks.py
Commands to run manually:
```sh
python manage.py celery -A news_aggregator_project worker --loglevel=info
```
```sh
celery -A djangoProject beat --loglevel=info
```