Skip to main content
Scrapling provides multiple ways to optimize scraping performance, from resource blocking to concurrent requests and page pooling.

Resource Blocking

Block unnecessary resources to speed up page loads:

Disable Resources

Block fonts, images, media, and other non-essential resources:
Blocked resource types:
  • font - Web fonts
  • image - Images and icons
  • media - Videos and audio
  • beacon - Analytics beacons
  • object - Embedded objects
  • imageset - Responsive images
  • texttrack - Video subtitles
  • websocket - WebSocket connections
  • csp_report - CSP reports
  • stylesheet - CSS files
Source: scrapling/engines/constants.py:2-13

Block Specific Domains

Block analytics and tracking domains:
Subdomains are automatically matched: blocking example.com also blocks sub.example.com.
Source: scrapling/engines/_browsers/_stealth.py:199

Concurrency Settings

Concurrent Requests

Control how many requests run simultaneously:
Source: scrapling/spiders/spider.py:76

Per-Domain Concurrency

Limit concurrent requests per domain to avoid overwhelming servers:
Source: scrapling/spiders/spider.py:77

Download Delay

Add delay between requests to the same domain:
Source: scrapling/spiders/spider.py:78

Page Pooling

Reuse browser pages instead of creating new ones:

Session Page Pooling

Configuration: scrapling/engines/_browsers/_validators.py:62

Pool Statistics

Monitor page pool usage:
Source: scrapling/engines/_browsers/_base.py:125-131

Network Optimization

Skip Network Idle

Don’t wait for network to be completely idle:
Only enable network_idle=True when you need to ensure all async requests complete. Source: scrapling/engines/_browsers/_stealth.py:52

Skip DOM Loading

For static content, skip waiting for JavaScript:
Disabling load_dom may result in incomplete content for JavaScript-heavy sites. Default is True.
Source: scrapling/engines/_browsers/_stealth.py:67

Reduce Wait Time

Minimize or remove post-load wait:
Source: scrapling/engines/_browsers/_stealth.py:54

Timeout Optimization

Set appropriate timeouts:
Lower timeouts fail faster on slow sites, higher timeouts give more time for complex pages. Source: scrapling/engines/_browsers/_stealth.py:53

Headless Mode

Always use headless mode in production:
Headful mode is 20-30% slower and should only be used for debugging. Source: scrapling/engines/_browsers/_stealth.py:46

Browser Flags

Scrapling uses optimized browser flags by default:
Source: scrapling/engines/constants.py:24-37 Add custom flags for additional optimization:

Complete Optimization Example

Maximum Speed Configuration

Balanced Configuration

For sites that need more stability:

Async Best Practices

Use uvloop

Use uvloop for faster async performance:
Source: scrapling/spiders/spider.py:264-281

Batch Processing

Process items in batches:

Memory Optimization

Parser Storage

For huge HTML documents, use disk-based storage:
Source: scrapling/engines/toolbelt/custom.py:140-154

Adaptive Parsing

Adaptive mode reduces memory for simple selections:
Source: scrapling/engines/toolbelt/custom.py:141

Benchmarking

Track performance metrics:

Performance Comparison

Best Practices

Measure performance before making changes:
Always block unnecessary resources:
Start conservative, increase gradually:
Monitor error rates as you increase concurrency.
Sessions reuse connections and browser instances:

Anti-Bot Bypass

Balance speed with stealth

Error Handling

Handle errors efficiently

Handling Blocked Requests

Retry strategies

Cloudflare Turnstile

Solve challenges faster