Scrapy Integration

Scale Scrapy spiders with residential proxy rotation

BytesFlows integrates with Scrapy's native HttpProxyMiddleware. Each request can exit through a different residential IP — preventing IP bans and rate limiting across long crawls.

Scrapy proxy configuration examples

BytesFlows works with Scrapy's built-in HttpProxyMiddleware and popular third-party rotation libraries.

settings.py
# settings.py

# Enable HTTP proxy middleware
DOWNLOADER_MIDDLEWARES = {
    'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 110,
}

# BytesFlows proxy credentials
# Using rotating mode: each request gets a different residential IP
HTTP_PROXY = 'http://YOUR_USER:YOUR_PASS@p1.bytesflows.com:8001'

# For SOCKS5 instead of HTTP:
# HTTP_PROXY = 'socks5://YOUR_USER:YOUR_PASS@p1.bytesflows.com:1080'

# Optional: Retry on proxy errors
RETRY_TIMES = 3
RETRY_HTTP_CODES = [500, 502, 503, 504, 408, 429]

Replace YOUR_USER and YOUR_PASS with credentials from BytesFlows Dashboard → Proxies → Residential → Sub-users. The rotating mode automatically selects a different exit IP for each request.

How Scrapy routes requests through BytesFlows

Scrapy's HttpProxyMiddleware intercepts outgoing download requests and forwards them through the configured proxy.

🕷️

Scrapy spider

Spider generates Request objects. HttpProxyMiddleware reads the HTTP_PROXY setting and attaches proxy credentials to each request.

⚙️

Downloader middleware

The middleware stack processes requests in priority order. HttpProxyMiddleware (priority 110) adds the Proxy-Authorization header.

🌐

BytesFlows gateway

The gateway validates credentials, selects a residential exit node based on any geo parameters in the username.

🏠

Residential exit

Request exits through a real home broadband IP. The target server sees a legitimate residential visitor, not a datacenter crawler.

BytesFlows supports both rotating and sticky session modes. Rotating mode (default) changes IP per request — ideal for bulk scraping. Sticky mode maintains IP for multi-step flows.

Built for production Scrapy pipelines

1

HttpProxyMiddleware compatibility

No third-party library needed. BytesFlows works with Scrapy's built-in HttpProxyMiddleware via a single setting in settings.py. SOCKS5 and HTTP both supported.

2

Works with scrapy-rotating-proxies

For proxy list rotation, add BytesFlows endpoints with different sub-user credentials to the ROTATING_PROXY_LIST. Each item gets a different residential exit IP for true rotation.

3

Retry-compatible proxy pool

BytesFlows gracefully handles retries — if an exit node is slow, the gateway automatically switches to a healthy node. Combine with Scrapy's RETRY_TIMES for resilient production pipelines.

Scrapy proxy technical FAQ

How do I use scrapy-rotating-proxies with BytesFlows?
Install scrapy-rotating-proxies (pip install scrapy-rotating-proxies) and add multiple BytesFlows proxy URLs to ROTATING_PROXY_LIST in settings.py. Each URL uses a different BytesFlows sub-user to get a different residential IP pool. The library handles rotation, deadpool, and retry logic automatically.
Does BytesFlows support Scrapy's AutoThrottle to avoid detection?
Yes. Enable AUTOTHROTTLE_ENABLED = True in settings.py. AutoThrottle adjusts request frequency based on server response latency. Combined with residential IPs, this mimics genuine user browsing patterns and significantly reduces detection and blocking rates.
Why do some Scrapy requests fail with 407 Proxy Authentication Required?
A 407 error means the proxy credentials weren't accepted. Verify your BytesFlows sub-user username and password from the dashboard. Ensure HTTP_PROXY format is correct: http://user:pass@host:port. For passwords with special characters (@, :, #), URL-encode them using Python's urllib.parse.quote().
Can I use SOCKS5 proxies with Scrapy?
Yes, but Scrapy doesn't support SOCKS5 natively. You need the scrapy-socks library (pip install scrapy-socks) and add SocksProxyMiddleware to DOWNLOADER_MIDDLEWARES. Then set your BytesFlows SOCKS5 endpoint (socks5://user:pass@p1.bytesflows.com:1080) in the middleware config.

Start scraping at scale with residential IPs

Get 1 GB free — enough to test your Scrapy spiders across multiple sites and geo targets.