Skip to main content
Web Scraping

How to Integrate Proxies Into Scrapy Spiders (2026)

Learn how to integrate proxies into Scrapy spiders with static setup, rotating middleware, and the right proxy type for your target.

ZenezenZenezen
·3 min read

AI Summary

Get a summary of this page using your preferred AI assistant.

How to Integrate Proxies Into Scrapy Spiders (2026)

Scrapy is one of the most efficient Python frameworks for large-scale web scraping, but sending all your requests from a single IP will get you blocked fast. Adding proxies to your Scrapy spiders routes each request through a different IP, keeping your scraper running without interruptions. Whether you are scraping e-commerce sites, search engines, or any target with rate limiting, proxy integration is the step that makes it production-ready.

In this article, we'll explore how to set up and configure proxies inside your Scrapy spiders the right way.


How to Add a Proxy to a Scrapy Spider

SCRAPY PROXY SETUP

The simplest way to add a proxy is through the HTTPPROXY_ENABLED setting in settings.py:

Python
1HTTPPROXY_ENABLED = True
2
3DOWNLOADER_MIDDLEWARES = {
4    'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 110,
5}
6
7HTTP_PROXY = 'http://username:password@proxy.proxyon.io:port'

This routes all requests through your proxy. For per-request control, pass the proxy through the request meta inside your spider:

Python
1def start_requests(self):
2    yield scrapy.Request(
3        url='https://example.com',
4        meta={'proxy': 'http://username:password@proxy.proxyon.io:port'}
5    )

Use this when you only need the proxy on specific requests rather than the entire spider.

Also Read: Datacenter Proxies for Web Scraping


Using Rotating Proxies with Scrapy Middleware

ROTATING PROXIES IN SCRAPY

Rotating proxies in Scrapy are best handled through a custom downloader middleware, which assigns a different IP to each request without touching your spider logic:

Python
1import random
2
3class RotatingProxyMiddleware:
4    def __init__(self):
5        self.proxies = [
6            'http://username:password@proxy.proxyon.io:port1',
7            'http://username:password@proxy.proxyon.io:port2',
8            'http://username:password@proxy.proxyon.io:port3',
9        ]
10
11    def process_request(self, request, spider):
12        request.meta['proxy'] = random.choice(self.proxies)

Register it in settings.py:

Python
1DOWNLOADER_MIDDLEWARES = {
2    'myproject.middlewares.RotatingProxyMiddleware': 100,
3}

With residential proxies, you skip the proxy list entirely. Rotation is handled on the backend through a single endpoint, so your middleware stays clean, and every request goes out through a different IP automatically.


Choosing the Right Proxy Type for Scrapy

BEST PROXY FOR SCRAPY

The proxy type you use depends entirely on what you are scraping. Residential proxies are the safest choice for heavily protected targets like e-commerce sites and search engines. They use IPs assigned to real households, making them nearly impossible to detect as automated traffic. Residential proxies start at $1.75/GB with no subscription required.

Datacenter proxies are faster and cheaper, and they work fine for targets without aggressive bot detection.

Mobile proxies are the hardest to block but also the most expensive. They are rarely necessary unless your target is specifically filtering out both residential and datacenter IPs.

A good rule of thumb: start with datacenter proxies and switch to residential if you are hitting blocks. Mobile proxies should be your last resort.

Also Read: How to Scrape a JavaScript Website With Python


Final Thought

Integrating proxies into Scrapy comes down to three things: the right setup, the right rotation method, and the right proxy type for your target. Proxyon's residential proxies start at $1.75/GB with no subscription. Get your endpoint at Proxyon and start scraping.

Related Posts

Everything you need to extract web data reliably.

Residential from $1.75/GB, datacenter from $1.50/IP, plus mobile, ISP, and IPv6. Pay-as-you-go. No subscriptions, no contracts. Deposit $5 and start today.

Get Started

Get 100MB free · No credit card required · Instant access