A sophisticated web scraping application that combines automated web scraping with AI-powered content parsing using Ollama LLM. This tool provides a user-friendly Streamlit interface for extracting and analyzing web content with intelligent data extraction capabilities.
- Automated Web Scraping: Uses Selenium WebDriver for robust web scraping
- AI-Powered Content Parsing: Leverages Ollama LLM for intelligent content extraction
- Captcha Handling: Integrated BrightData proxy service for bypassing captchas
- Web Interface: Clean Streamlit-based user interface
- Content Cleaning: Automatic removal of scripts, styles, and formatting
- Chunked Processing: Handles large content by splitting into manageable chunks
- Real-time Processing: Live scraping and parsing with progress indicators
- Streamlit (v1.28.0+) - Web application framework
- Selenium (v4.15.0+) - Web automation and scraping
- BeautifulSoup4 (v4.12.0+) - HTML parsing and content extraction
- LangChain (v0.1.0+) - LLM integration framework
- Ollama - Local LLM for content parsing
- NumPy (v1.24.0+) - Numerical computing
- Requests (v2.31.0+) - HTTP library
- LXML (v4.9.0+) - XML/HTML processing
- Python 3.8 or higher
- Chrome browser installed
- Internet connection
- Ollama installed and running locally
- BrightData (optional) - For captcha bypassing and proxy services
- Ollama - Local LLM service (llama3 model recommended)
-
Clone the repository
git clone <repository-url> cd AI-WebScrapper_c
-
Install Python dependencies
pip install -r requirements.txt
-
Install Ollama (if not already installed)
# Follow instructions at https://ollama.ai/ ollama pull llama3 -
Set up BrightData (optional)
- Sign up for BrightData account
- Update credentials in
scrape.pyif using proxy services
streamlit run main.py- Enter Website URL: Input the target website URL in the text field
- Scrape Content: Click "Scrape Site" to extract website content
- Review Content: View the extracted DOM content in the expandable section
- Define Parsing Criteria: Describe what information you want to extract
- Parse Content: Click "Parse Content" to get AI-processed results
- Extract product information from e-commerce sites
- Gather news articles and headlines
- Collect contact information from business directories
- Extract pricing data from competitor websites
- Gather research data from academic or news websites
scrape_website(url): Main scraping function using Seleniumextract_body_content(html): Extracts body content from HTMLclean_body_content(content): Removes scripts, styles, and formats textsplit_dom_content(content, max_length): Splits large content into chunks
parse_with_ollama(chunks, description): Processes content with Ollama LLM- Uses LangChain for prompt management and LLM integration
- Implements chunked processing for large content
- Streamlit-based user interface
- Session state management for content persistence
- Real-time progress indicators
URL Input β Web Scraping β Content Extraction β Content Cleaning β
Chunking β AI Parsing β Results Display
Update the following variables in scrape.py:
AUTH = 'YOUR_USERNAME:YOUR_PASSWORD'
SBR_WEBDRIVER = 'YOUR_BRIGHTDATA_ENDPOINT'- Ensure Ollama is running locally
- Default model:
llama3 - Can be modified in
parse.py:
model = OllamaLLM(model="your-preferred-model")- Default chunk size: 6000 characters
- Adjustable in
split_dom_content()function
-
ChromeDriver Issues
- Ensure Chrome browser is installed
- Download appropriate ChromeDriver version
- Update path in
scrape.pyif using local ChromeDriver
-
Ollama Connection Issues
- Verify Ollama is running:
ollama list - Check if llama3 model is available:
ollama pull llama3 - Ensure Ollama service is accessible on default port
- Verify Ollama is running:
-
BrightData Connection Issues
- Verify credentials are correct
- Check account status and quota
- Ensure proxy endpoint is accessible
-
Memory Issues with Large Content
- Reduce chunk size in
split_dom_content() - Process smaller websites
- Monitor system memory usage
- Reduce chunk size in
- Use appropriate chunk sizes for your content
- Implement caching for frequently accessed websites
- Consider rate limiting for large-scale scraping
- Monitor memory usage with large content processing
- The application can handle multiple concurrent users
- Consider implementing database storage for large datasets
- Add queue management for batch processing
- Use HTTPS URLs when possible
- Implement rate limiting to avoid being blocked
- Respect robots.txt files
- Use proxy services responsibly
- Secure API credentials and configuration
- Ensure compliance with website terms of service
- Implement data retention policies
- Secure storage of scraped content
- Respect user privacy and data protection laws
- Test with various website types
- Verify content extraction accuracy
- Test AI parsing with different descriptions
- Validate error handling
- Unit tests for core functions
- Integration tests for end-to-end workflow
- Performance benchmarking
- Error scenario testing
- Multi-Model Support: Integration with additional LLM providers (OpenAI, Anthropic, etc.)
- Custom Model Training: Fine-tune models for specific domains or use cases
- Advanced Prompt Engineering: Implement more sophisticated prompting strategies
- Semantic Search: Add vector-based search capabilities for better content understanding
- Dashboard Analytics: Add visualization of scraping statistics and trends
- Batch Processing: Support for processing multiple URLs simultaneously
- Scheduled Scraping: Implement cron-based automated scraping
- Export Functionality: Add support for exporting results in various formats (CSV, JSON, Excel)
- Template Library: Pre-built parsing templates for common use cases
- Database Integration: Add persistent storage for scraped data and results
- API Endpoints: Create RESTful API for programmatic access
- Microservices Architecture: Split into separate services for better scalability
- Containerization: Docker support for easy deployment
- Cloud Deployment: AWS, Azure, or GCP deployment options
- Dynamic Content Handling: Better support for JavaScript-heavy websites
- Image and Media Extraction: Extract and process images, videos, and other media
- Multi-language Support: Internationalization for global users
- Real-time Monitoring: Live monitoring of scraping processes
- Advanced Error Recovery: Intelligent retry mechanisms and error handling
- Caching Layer: Implement Redis or similar for caching frequently accessed content
- Async Processing: Convert to async/await for better performance
- Load Balancing: Distribute scraping load across multiple instances
- CDN Integration: Optimize content delivery for global users
- Robots.txt Compliance: Automatic robots.txt checking and compliance
- Rate Limiting: Intelligent rate limiting based on website policies
- Ethical Guidelines: Built-in ethical scraping guidelines and warnings
- Audit Trail: Comprehensive logging for compliance and debugging
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- Follow PEP 8 style guidelines
- Add docstrings for all functions
- Include type hints where appropriate
- Write comprehensive commit messages
This project is licensed under the MIT License - see the LICENSE file for details.
- BrightData for proxy and captcha solving services
- Ollama for local LLM capabilities
- Streamlit for the web interface framework
- Selenium for web automation capabilities
- BeautifulSoup for HTML parsing
For issues, questions, or contributions:
- Create an issue in the repository
- Check the troubleshooting section
- Review the documentation
Note: This tool is designed for educational and research purposes. Please ensure compliance with website terms of service and applicable laws when using this application.