Advanced dynamic web scraper with Cloudflare bypass, JS rendering, Selenium, Playwright fallback and adaptive extraction.
Project description
๐ Dynamic Web Scraper - Enterprise-Grade Data Intelligence Platform
๐ Overview
Dynamic Web Scraper is a sophisticated, enterprise-grade Python platform for extracting, analyzing, and visualizing data from dynamic websites. It has evolved from a basic scraper into a comprehensive data intelligence platform with advanced features including intelligent site detection, automated data enrichment, price analysis, comparative analysis, and interactive dashboards.
โจ Key Features
๐ง Intelligent Site Detection & Adaptation
- Automatic site type detection (e-commerce, blog, news, etc.)
- Dynamic CSS selector generation based on site patterns
- Smart product element detection (titles, prices, images, links)
- Site-specific rule caching for improved performance
- Anti-bot measure detection and adaptive responses
๐ฏ Advanced Data Processing & Enrichment
- Automatic data cleaning and normalization
- Price normalization across different currencies and formats
- Contact information extraction from product descriptions
- Category classification using intelligent algorithms
- Quality scoring and outlier detection
- Data validation and integrity checks
๐ Comprehensive Analytics & Visualization
- Interactive data visualization with Plotly charts
- Price distribution analysis with statistical insights
- Trend detection with time-series analysis
- Comparative analysis across sources and categories
- Heatmap visualizations for pattern recognition
- Summary dashboards with comprehensive metrics
- Export capabilities for reports and presentations
๐ก๏ธ Advanced Anti-Bot Evasion
- Multiple stealth profiles (stealth, mobile, aggressive)
- Browser fingerprint spoofing and header manipulation
- Human-like timing delays and behavior simulation
- Undetected ChromeDriver integration for maximum stealth
- Session persistence and cookie management
- CAPTCHA detection and handling capabilities
- Automatic browser automation fallback for JavaScript-heavy sites
๐ Distributed Scraping & Processing
- Job Queue System with priority-based scheduling
- Worker Pool Management for parallel processing
- Thread-safe Operations with persistent storage
- Real-time Monitoring and statistics
- Automatic Retry Logic and error recovery
- Scalable Architecture for enterprise use
๐จ Plugin System & Extensibility
- Plugin System with multiple plugin types (data processors, validators, custom scrapers)
- Configuration Management with multi-format support (JSON, YAML, TOML)
- Environment Variable Overrides for flexible deployment
- Template Generation for easy plugin development
- Runtime Configuration management and validation
๐ Price Analysis & Time Series
- Statistical analysis (mean, median, std dev, skewness)
- Trend detection (linear regression, moving averages)
- Seasonality analysis (autocorrelation, pattern recognition)
- Anomaly detection (Z-score, IQR, rolling statistics)
- Price prediction with confidence intervals
- Intelligent recommendations based on analysis
๐ Comparative Analysis & Deal Discovery
- Cross-site price comparison with comprehensive analysis
- Intelligent product matching using similarity algorithms
- Brand and model extraction for accurate identification
- Deal scoring and classification with savings analysis
- Best deal discovery with ranking and recommendations
- Price variance analysis with statistical insights
๐ง Automated Reporting & Alerts
- Scheduled reports with daily and weekly automation
- Email notifications for price changes and anomalies
- Configurable alert thresholds for price drops and increases
- Statistical anomaly detection using z-score analysis
- HTML email templates with detailed alert information
- Background scheduling with automated report generation
๐ Interactive Web Dashboard
- Real-time monitoring of scraping jobs
- Interactive charts and statistics
- Site analysis and visualization
- Job queue management
- Results viewing and export
- Responsive interface with modern design
๐ฆ Multi-Format Export & Sharing
- Multiple output formats (JSON, CSV, Excel, ZIP)
- Comprehensive data packaging with metadata
- Export history tracking and management
- Automatic file cleanup and maintenance
- Slack integration for automated sharing
- Batch export capabilities for multiple formats
๐ Requirements
- Python 3.8 or later
- Google Chrome or Firefox (for Selenium)
- All dependencies are version-pinned in
requirements.txt
๐ฆ Installation
Quick Start
# Clone the repository
git clone <repository-url>
cd dynamic_web_scraper
# Create virtual environment
python -m venv .venv
.venv\Scripts\activate # Windows
# or
source .venv/bin/activate # Mac/Linux
# Install production dependencies (backward compatible)
pip install -r requirements.txt
# Or install only core dependencies (minimal installation)
pip install -r requirements/base.txt
# Install development dependencies (optional)
pip install -r requirements-dev.txt
# Setup and test the scraper
python setup_and_test.py
Modular Installation (Recommended)
# Core scraping only (minimal installation)
pip install -r requirements/base.txt
# Core + data analysis and visualization
pip install -r requirements/base.txt -r requirements/data.txt
# Core + advanced features (Cloudflare bypass, Flask dashboard)
pip install -r requirements/base.txt -r requirements/advanced.txt
# Full development environment
pip install -r requirements/all.txt
See requirements/README.md for detailed dependency documentation.
Development Setup
# Install all dependencies including development tools
pip install -r requirements-dev.txt
# Run the comprehensive test suite
python tests/run_tests.py --all --coverage
# Format and lint the code
black scraper/
flake8 scraper/
๐ Quick Start
Option 1: Web Dashboard (Recommended)
# Start the web dashboard
python run_dashboard.py
The dashboard will automatically open in your browser at http://localhost:5000
Option 2: Command Line
# Run the scraper directly
python scraper/main.py
โ Configuration
All settings are managed in config.json:
{
"user_agents": [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36...",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)..."
],
"proxies": [
"http://proxy1.example.com:8080",
"http://proxy2.example.com:8080"
],
"use_proxy": true,
"max_retries": 3,
"retry_delay": 2,
"rate_limiting": {
"requests_per_minute": 60
}
}
๐ฏ Usage
๐ Automatic Workflow with All Advanced Features
The scraper now automatically uses all advanced features in a comprehensive workflow:
Step 1: Smart Site Detection
- Automatically detects site type and anti-bot measures
- Generates optimal CSS selectors
- Adapts to different site structures
Step 2: Data Extraction & Enrichment
- Extracts raw data with intelligent parsing
- Cleans and normalizes data
- Adds quality scores and metadata
- Extracts contact information and categories
Step 3: Advanced Analysis
- Price Analysis: Statistical analysis, outlier detection, trend analysis
- Comparative Analysis: Cross-site price comparison, deal scoring
- Time Series Analysis: Trend detection, seasonality, predictions
- Data Visualization: Interactive charts and dashboards
Step 4: Automated Reporting
- Generates comprehensive reports
- Sends email alerts for anomalies
- Creates interactive dashboards
- Exports data in multiple formats
Step 5: Plugin Processing
- Applies custom data processors
- Validates data quality
- Enhances data with external sources
Step 6: Distributed Processing
- Queues jobs for parallel processing
- Manages worker pools
- Handles large-scale operations
๐ What You Get Automatically
- Raw data in multiple formats
- Enriched data with quality scores and metadata
- Price analysis with statistical insights
- Cross-site comparisons and best deals
- Interactive visualizations and dashboards
- Automated reports with alerts and recommendations
- Multiple export formats for different use cases
Web Dashboard Features
1. Dashboard Overview
- Real-time statistics (total jobs, success rate, results count)
- Interactive charts (success rate trends, job status distribution)
- Recent jobs list with status indicators
- Active jobs monitoring with live duration tracking
2. Start Scraping
- URL input with validation
- Output format selection (CSV, JSON, Excel)
- Advanced options (proxy rotation, Selenium)
- Site analysis before scraping
- Real-time feedback and progress tracking
3. Job Management
- Job status tracking (pending, running, completed, failed)
- Results viewing with pagination
- Error handling and debugging information
- Export capabilities for scraped data
4. Site Analysis
- Automatic site type detection
- E-commerce pattern recognition
- CSS selector generation
- Confidence scoring
Command Line Usage
# Basic usage
python scraper/main.py
# You will be prompted for:
# - Target URL
# - Output file path (default: data/all_listings.csv)
๐ Project Structure
dynamic_web_scraper/
โโโ scraper/ # Core scraping logic
โ โโโ main.py # Command line entry point
โ โโโ Scraper.py # Main scraper class with all features
โ โโโ config.py # Configuration management
โ โโโ dashboard/ # Web dashboard
โ โ โโโ app.py # Flask application
โ โ โโโ templates/ # HTML templates
โ โโโ analytics/ # Data analysis and visualization
โ โ โโโ data_visualizer.py # Interactive charts and dashboards
โ โ โโโ price_analyzer.py # Price analysis and statistics
โ โ โโโ time_series_analyzer.py # Time series analysis and prediction
โ โโโ comparison/ # Cross-site comparison
โ โ โโโ site_comparator.py # Product matching and deal analysis
โ โโโ reporting/ # Automated reporting
โ โ โโโ automated_reporter.py # Reports, alerts, and notifications
โ โโโ export/ # Data export and sharing
โ โ โโโ export_manager.py # Multi-format export capabilities
โ โโโ plugins/ # Plugin system
โ โ โโโ plugin_manager.py # Plugin management and extensibility
โ โโโ distributed/ # Distributed processing
โ โ โโโ job_queue.py # Job queue system
โ โ โโโ worker_pool.py # Worker pool management
โ โโโ anti_bot/ # Anti-bot evasion
โ โ โโโ stealth_manager.py # Stealth and anti-detection
โ โโโ site_detection/ # Intelligent site detection
โ โ โโโ site_detector.py # Site structure detection
โ โ โโโ html_analyzer.py # HTML analysis
โ โ โโโ css_selector_builder.py # Selector building
โ โโโ css_selectors/ # Dynamic selector system
โ โ โโโ css_selector_generator.py # Selector generation
โ โ โโโ css_rules.py # Rule management
โ โ โโโ dynamic_selector.py # Site adaptation
โ โโโ data_parsers/ # Data processing
โ โโโ proxy_manager/ # Proxy handling
โ โโโ user_agent_manager/ # User agent management
โ โโโ logging_manager/ # Logging system
โ โโโ exceptions/ # Custom exceptions
โโโ tests/ # Comprehensive test suite
โ โโโ core/ # Core functionality tests
โ โโโ analytics/ # Analytics and visualization tests
โ โโโ site_detection/ # Site detection tests
โ โโโ utils/ # Utility function tests
โ โโโ integration/ # Integration tests
โ โโโ conftest.py # Pytest configuration and fixtures
โ โโโ run_tests.py # Test runner script
โโโ data/ # Output data storage
โโโ logs/ # Log files
โโโ config.json # Configuration
โโโ requirements/ # Organized dependency files
โ โโโ base.txt # Core dependencies
โ โโโ web.txt # Scheduling features
โ โโโ data.txt # Data analysis (optional)
โ โโโ advanced.txt # Experimental features
โ โโโ testing.txt # Testing framework
โ โโโ dev.txt # Development tools
โ โโโ all.txt # All dependencies
โ โโโ README.md # Dependency documentation
โโโ requirements.txt # Backward compatibility wrapper
โโโ requirements-dev.txt # Backward compatibility wrapper
โโโ pytest.ini # Pytest configuration
โโโ run_dashboard.py # Dashboard launcher
โโโ README.md # Documentation
๐งช Testing
The project includes a comprehensive, organized test suite with professional structure:
Run All Tests
# Run the complete test suite
python tests/run_tests.py --all
# Run with coverage
python tests/run_tests.py --all --coverage
# Run with HTML report
python tests/run_tests.py --all --html
Run Specific Test Categories
# Core functionality tests
python tests/run_tests.py --category core
# Analytics and visualization tests
python tests/run_tests.py --category analytics
# Site detection tests
python tests/run_tests.py --category site_detection
# Utility function tests
python tests/run_tests.py --category utils
# Integration tests
python tests/run_tests.py --category integration
Quick Tests (Unit Tests Only)
# Run only unit tests (fast)
python tests/run_tests.py --quick
Test Categories Available
| Category | Location | Purpose |
|---|---|---|
| core | tests/core/ |
Basic scraper functionality and integration |
| analytics | tests/analytics/ |
Data analysis and visualization |
| site_detection | tests/site_detection/ |
Site detection and CSS selector generation |
| utils | tests/utils/ |
Utility functions |
| integration | tests/integration/ |
Complete workflow testing |
Direct Pytest Commands
# Run all tests
pytest tests/
# Run specific category
pytest tests/analytics/
# Run with markers
pytest -m "not slow"
pytest -m integration
๐ Example Output
CSV Output
title,price,image,link,quality_score,category,source
iPhone 13 Pro,$999.99,https://example.com/iphone.jpg,https://example.com/iphone,0.95,electronics,amazon
Samsung Galaxy S21,$899.99,https://example.com/samsung.jpg,https://example.com/samsung,0.92,electronics,ebay
JSON Output with Enrichment
[
{
"title": "iPhone 13 Pro",
"price": 999.99,
"currency": "USD",
"image": "https://example.com/iphone.jpg",
"link": "https://example.com/iphone",
"quality_score": 0.95,
"category": "electronics",
"source": "amazon",
"extracted_contacts": [],
"price_analysis": {
"is_outlier": false,
"price_percentile": 75,
"trend": "stable"
}
}
]
Interactive Dashboard
- Real-time charts and visualizations
- Interactive filtering by source, category, date
- Price distribution analysis with histograms
- Trend analysis with moving averages
- Comparative analysis across sources
๐ง Advanced Features
Intelligent Site Detection
The scraper automatically:
- Detects site type (e-commerce, blog, news, etc.)
- Identifies product patterns (shopping cart, prices, add to cart buttons)
- Generates appropriate CSS selectors
- Adapts to different site structures
- Caches site analysis for improved performance
Dynamic CSS Selector Generation
- Smart selector strategies based on element attributes
- Fallback mechanisms for when primary selectors fail
- Validation and optimization of generated selectors
- Site-specific caching for improved performance
- Multiple selector types (ID, class, smart, path-based)
Anti-Detection Measures
- User agent rotation from a large pool of realistic browsers
- Proxy rotation with automatic failover
- Rate limiting with random delays
- Request header randomization
- Browser fingerprint spoofing
- Human-like behavior simulation
Robust Error Handling
- Retry logic with exponential backoff
- Graceful degradation when selectors fail
- Comprehensive logging for debugging
- Custom exceptions with helpful error messages
- Automatic recovery from common failures
๐ Performance & Scalability
Optimizations
- Asynchronous processing for multiple jobs
- Database caching for site analysis results
- Efficient memory usage with streaming data processing
- Background job processing with queue management
- Parallel processing with worker pools
Monitoring
- Real-time job status tracking
- Performance metrics and statistics
- Error rate monitoring
- Resource usage tracking
- Comprehensive logging and debugging
๐ Security & Privacy
- No sensitive data logging (credentials, API keys)
- Input validation and sanitization
- Secure configuration management
- Respect for robots.txt (configurable)
- Data encryption for sensitive information
- Access control and authentication
๐ค Contributing
We welcome contributions! Please see our CONTRIBUTING.md for detailed guidelines.
Development Setup
# Install development dependencies
pip install -r requirements-dev.txt
# Run the comprehensive test suite
python tests/run_tests.py --all --coverage
# Format code
black scraper/
# Lint code
flake8 scraper/
# Type checking
mypy scraper/
Code Quality
- Pre-commit hooks for automatic code formatting
- Comprehensive testing with pytest
- Code coverage reporting
- Static analysis with mypy and flake8
- Security scanning with bandit
๐ Logging & Troubleshooting
Log Files
- Main logs:
logs/scraper.log - Error logs:
logs/error_YYYY-MM-DD.log - Dashboard logs: Console output
- Test logs:
logs/test_YYYY-MM-DD.log
Common Issues
Import Errors
# Ensure all dependencies are installed
pip install -r requirements.txt
# Or install specific dependencies as needed
pip install -r requirements/base.txt
Selenium Issues
# Install webdriver-manager
pip install webdriver-manager
# The scraper will automatically download drivers
Proxy Issues
# Check proxy configuration in config.json
# Disable proxy rotation if needed
Test Issues
# Run tests with verbose output
python tests/run_tests.py --all --verbose
# Check test configuration
python tests/run_tests.py --list
๐ License
This project is licensed under the Apache License 2.0 โ see the LICENSE file for details.
๐ What's New in This Version
v0.9 - Enterprise Data Intelligence Platform
- โ Complete Test Organization - Professional test suite with organized structure
- โ Integrated Advanced Features - All features working together seamlessly
- โ Comprehensive Analytics - Data visualization, price analysis, time series
- โ Distributed Processing - Job queues, worker pools, parallel processing
- โ Plugin System - Extensible architecture with custom plugins
- โ Automated Reporting - Scheduled reports, email alerts, notifications
- โ Comparative Analysis - Cross-site price comparison and deal discovery
- โ Multi-Format Export - JSON, CSV, Excel, ZIP with metadata
- โ Interactive Dashboards - Web-based data exploration and visualization
- โ Advanced Anti-Bot Evasion - Multiple stealth profiles and detection avoidance
๐ฏ Ready to Get Started?
- Quick Start: Run
python run_dashboard.pyfor the web interface - Command Line: Use
python scraper/main.pyfor direct scraping - Testing: Run
python tests/run_tests.py --allto verify everything works - Development: Install dev dependencies with
pip install -r requirements-dev.txt
๐ Transform your web scraping into a comprehensive data intelligence platform!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dynamic_web_scraper-1.0.0.tar.gz.
File metadata
- Download URL: dynamic_web_scraper-1.0.0.tar.gz
- Upload date:
- Size: 157.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
854ec2873dda33d6b5d273f43f89cfc987c28fbd20f871c76fc0577303d353bf
|
|
| MD5 |
72b5fb95131699730cb4c1743ea7d517
|
|
| BLAKE2b-256 |
289b23759bb2db5f5ce644d0447e62b20eef739414433fe985d300e191c6539a
|
File details
Details for the file dynamic_web_scraper-1.0.0-py3-none-any.whl.
File metadata
- Download URL: dynamic_web_scraper-1.0.0-py3-none-any.whl
- Upload date:
- Size: 203.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
749b397a9a2e91509506de6d52780d7a79c8d7acdbfac1665c3c5208eb1b1d99
|
|
| MD5 |
3f46efd6b0930476516d6f3b0a0457f9
|
|
| BLAKE2b-256 |
0f9f7402137f8a9d895ec2437006a90b4b0fcde51b6908f880130197a5b39fbf
|