A multi-agent system that scrapes financial news websites and generates market sentiment analysis using LangChain and Ollama.
- Web scraping with robust error handling
- 404 error handling
- SSL certificate issues
- Rate limiting with exponential backoff
- Cookie management
- Timeout handling
- Connection error handling
- Sentiment analysis using Ollama LLM
- Configurable parameters for scraping scope
- Detailed logging system
- Python 3.8+
- Ollama installed and running locally
- The llama2 model installed in Ollama
- Clone the repository:
git clone <repository-url>
cd market-sentiment-analysis
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Install and run Ollama:
# Install Ollama from: https://ollama.ai/
ollama pull llama2
src/
├── agents/
│ ├── scraping_agent.py
│ └── sentiment_agent.py
├── config.py
├── main.py
└── test_market_analysis.py
You can configure the system by modifying the ScrapingConfig
in config.py
:
max_pages
: Maximum number of pages to scrapedays_to_scrape
: Time window for article collectionbase_urls
: List of URLs to scraperetry_attempts
: Number of retry attempts for failed requeststimeout
: Request timeout in seconds
- Ensure Ollama is running with the llama2 model:
ollama run llama2
- Run the test script:
python src/test_market_analysis.py
The system handles various common errors:
- Network connectivity issues
- Rate limiting
- SSL certificate errors
- Invalid URLs
- Timeout errors
- Cookie consent prompts
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.