Integration
Scrapy Integration - Rotating Proxies (Middleware Setup)
Configure Scrapy to use rotating proxies and handle bans/timeouts with middleware and retries.
PT
Technical Team
Author
January 12, 2026
Published
8 min read
Reading time
#scrapy#rotation#middleware
Overview
Scrapy scales fast, so proxy + retry config matters. This guide shows a clean middleware approach and safe defaults for rotating Proxiesseller proxies.
Installation & Setup
Install Scrapy:
pip install scrapyExamples
settings.py (recommended defaults)
DOWNLOADER_MIDDLEWARES = {
"scrapy.downloadermiddlewares.retry.RetryMiddleware": 90,
}
RETRY_ENABLED = True
RETRY_TIMES = 3
DOWNLOAD_TIMEOUT = 25
CONCURRENT_REQUESTS = 16Use a single proxy (quick test)
# in your spider:
def start_requests(self):
yield scrapy.Request(
url="https://api.ipify.org",
meta={"proxy": "http://USER:PASS@HOST:PORT"},
callback=self.parse
)Rotate proxies (list)
Pick a proxy per request (simple rotation).
import random
PROXIES = [
"http://USER:PASS@HOST1:PORT",
"http://USER:PASS@HOST2:PORT",
]
def process_request(request, spider):
request.meta["proxy"] = random.choice(PROXIES)Troubleshooting
- If requests hang: increase DOWNLOAD_TIMEOUT and reduce concurrency
- If some sites block: enable cookies, use realistic headers, slow down
- If proxy auth fails: verify proxy URL format in meta['proxy']
Pro Tip
For best success rate, use sticky sessions per domain (same IP for a short time), then rotate.