Skip to main content

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?

  1. Quick Start: Run python run_dashboard.py for the web interface
  2. Command Line: Use python scraper/main.py for direct scraping
  3. Testing: Run python tests/run_tests.py --all to verify everything works
  4. Development: Install dev dependencies with pip install -r requirements-dev.txt

๐Ÿš€ Transform your web scraping into a comprehensive data intelligence platform!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dynamic_web_scraper-1.0.0.tar.gz (157.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dynamic_web_scraper-1.0.0-py3-none-any.whl (203.2 kB view details)

Uploaded Python 3

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

Hashes for dynamic_web_scraper-1.0.0.tar.gz
Algorithm Hash digest
SHA256 854ec2873dda33d6b5d273f43f89cfc987c28fbd20f871c76fc0577303d353bf
MD5 72b5fb95131699730cb4c1743ea7d517
BLAKE2b-256 289b23759bb2db5f5ce644d0447e62b20eef739414433fe985d300e191c6539a

See more details on using hashes here.

File details

Details for the file dynamic_web_scraper-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dynamic_web_scraper-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 749b397a9a2e91509506de6d52780d7a79c8d7acdbfac1665c3c5208eb1b1d99
MD5 3f46efd6b0930476516d6f3b0a0457f9
BLAKE2b-256 0f9f7402137f8a9d895ec2437006a90b4b0fcde51b6908f880130197a5b39fbf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page