Hype Proxies

How to use a proxy with Scrapy

This guide shows you how to integrate HypeProxies with Scrapy to handle IP restrictions, geographical limitations, and rate limiting in your web scraping applications.

No credit card required. Request your free trial today.

Speed

Success

Consistency

Reliability

Flexibility

What is Scrapy

Scrapy is a powerful open-source Python framework for web scraping and crawling. It enables you to write spiders that extract data from websites efficiently. However, when scraping at scale, you often encounter IP bans, geo-restrictions, and rate limits that can halt your data collection efforts.

Proxies solve these challenges by masking your IP address and enabling you to rotate between different network endpoints, helping you avoid detection and maintain consistent access to your target websites.

Scrapy homepage mockup

Prerequisites and setup

Before adding proxies to your project, make sure you have:

  • Python 3.9+ installed

  • Latest Scrapy framework set up (pip install scrapy)

  • HypeProxies account with active proxy credentials

  • Basic familiarity with Scrapy spiders

If you’re new to Scrapy, start with the official installation guide and tutorial on creating a project.

Get your HypeProxies credentials

HypeProxies provides unlimited bandwidth, a 10 Gbps network and unlimited concurrency. Our clean static residential proxies come from trusted U.S. carriers.

Hypeproxies dashboard

Now, to get the credential from HypeProxies, follow the steps below:

  1. Create your HypeProxies account (submit a support ticket for a 48-hour free trial)

  2. Select your proxy plan (ISP, Sneaker, or Ticket proxies)

  3. Complete the checkout process

  4. Access your proxy list from the dashboard

  5. Note the credential format: IP:PORT:USERNAME:PASSWORD

  6. (Optional) Test your proxy connectivity using our proxy checker tool before integrating it into your project

Method 1 – per-request configuration

To quickly test your HypeProxies setup or apply a proxy to specific requests, you can assign it inline using the meta parameter.

import scrapy


class ProxyTestSpider(scrapy.Spider):
    name = "proxy_test"
    start_urls = ["https://ipapi.co/json/"]

    async def start(self):
        proxy = "http://username:password@proxy_ip:proxy_port"

        for url in self.start_urls:
            yield scrapy.Request(url=url, callback=self.parse, meta={"proxy": proxy})

    def parse(self, response):
        data = response.json()
        self.logger.info(f"Response: {data}"

import scrapy


class ProxyTestSpider(scrapy.Spider):
    name = "proxy_test"
    start_urls = ["https://ipapi.co/json/"]

    async def start(self):
        proxy = "http://username:password@proxy_ip:proxy_port"

        for url in self.start_urls:
            yield scrapy.Request(url=url, callback=self.parse, meta={"proxy": proxy})

    def parse(self, response):
        data = response.json()
        self.logger.info(f"Response: {data}"

import scrapy


class ProxyTestSpider(scrapy.Spider):
    name = "proxy_test"
    start_urls = ["https://ipapi.co/json/"]

    async def start(self):
        proxy = "http://username:password@proxy_ip:proxy_port"

        for url in self.start_urls:
            yield scrapy.Request(url=url, callback=self.parse, meta={"proxy": proxy})

    def parse(self, response):
        data = response.json()
        self.logger.info(f"Response: {data}"

Replace username, password, proxy_ip, and proxy_port with your actual HypeProxies credentials.

Then run your spider: scrapy crawl proxy_test

If successful, you’ll see output like:

This spider sends a request through your proxy to a public IP checker. If everything's set up correctly, the IP in the response will be different from your local IP, confirming that your HypeProxies setup is active.

Method 2 – middleware management

If you want every request in your Scrapy project to use the same proxy, add a custom middleware:

# middlewares.py
from scrapy.exceptions import NotConfigured

class ProxyMiddleware:
    def __init__(self, proxy_url):
        self.proxy_url = proxy_url
    
    @classmethod
    def from_crawler(cls, crawler):
        proxy_url = crawler.settings.get('PROXY_URL')
        if not proxy_url:
            raise NotConfigured('PROXY_URL setting is required')
        return cls(proxy_url)
    
    def process_request(self, request, spider):
        if "proxy" not in request.meta:
            request.meta["proxy"

# middlewares.py
from scrapy.exceptions import NotConfigured

class ProxyMiddleware:
    def __init__(self, proxy_url):
        self.proxy_url = proxy_url
    
    @classmethod
    def from_crawler(cls, crawler):
        proxy_url = crawler.settings.get('PROXY_URL')
        if not proxy_url:
            raise NotConfigured('PROXY_URL setting is required')
        return cls(proxy_url)
    
    def process_request(self, request, spider):
        if "proxy" not in request.meta:
            request.meta["proxy"

# middlewares.py
from scrapy.exceptions import NotConfigured

class ProxyMiddleware:
    def __init__(self, proxy_url):
        self.proxy_url = proxy_url
    
    @classmethod
    def from_crawler(cls, crawler):
        proxy_url = crawler.settings.get('PROXY_URL')
        if not proxy_url:
            raise NotConfigured('PROXY_URL setting is required')
        return cls(proxy_url)
    
    def process_request(self, request, spider):
        if "proxy" not in request.meta:
            request.meta["proxy"

Then activate the middleware in your settings.py:

# settings.py
DOWNLOADER_MIDDLEWARES = {
    'myproject.middlewares.ProxyMiddleware': 100,
    'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 110,
}

PROXY_URL = "http://username:password@proxy_ip:proxy_port"
# settings.py
DOWNLOADER_MIDDLEWARES = {
    'myproject.middlewares.ProxyMiddleware': 100,
    'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 110,
}

PROXY_URL = "http://username:password@proxy_ip:proxy_port"
# settings.py
DOWNLOADER_MIDDLEWARES = {
    'myproject.middlewares.ProxyMiddleware': 100,
    'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 110,
}

PROXY_URL = "http://username:password@proxy_ip:proxy_port"

With this setup, your spider code stays clean:

import scrapy

class ProxyTestSpider(scrapy.Spider):
    name = "proxy_test"
    start_urls = ["https://ipapi.co/json/"]

    async def start(self):
        for url in self.start_urls:
            yield scrapy.Request(url=url, callback=self.parse)

    def parse(self, response):
        data = response.json()
        self.logger.info(f"Response: {data}"

import scrapy

class ProxyTestSpider(scrapy.Spider):
    name = "proxy_test"
    start_urls = ["https://ipapi.co/json/"]

    async def start(self):
        for url in self.start_urls:
            yield scrapy.Request(url=url, callback=self.parse)

    def parse(self, response):
        data = response.json()
        self.logger.info(f"Response: {data}"

import scrapy

class ProxyTestSpider(scrapy.Spider):
    name = "proxy_test"
    start_urls = ["https://ipapi.co/json/"]

    async def start(self):
        for url in self.start_urls:
            yield scrapy.Request(url=url, callback=self.parse)

    def parse(self, response):
        data = response.json()
        self.logger.info(f"Response: {data}"

This method centralizes proxy handling – no need to manually assign the proxy for each request.

Method 3 – automatic rotation

For rotating through multiple proxies with health monitoring:

Install the rotation package:

pip install scrapy-rotating-proxies
pip install scrapy-rotating-proxies
pip install scrapy-rotating-proxies

Configure settings:

# settings.py
DOWNLOADER_MIDDLEWARES = {
    'rotating_proxies.middlewares.RotatingProxyMiddleware': 610,
    'rotating_proxies.middlewares.BanDetectionMiddleware': 620,
}

ROTATING_PROXY_LIST = [
    "http://user1:pass1@ip1:port1",
    "http://user2:pass2@ip2:port2",
    "http://user3:pass3@ip3:port3",
]

RETRY_TIMES = 5
RETRY_HTTP_CODES = [403, 429, 500, 502, 503, 504

# settings.py
DOWNLOADER_MIDDLEWARES = {
    'rotating_proxies.middlewares.RotatingProxyMiddleware': 610,
    'rotating_proxies.middlewares.BanDetectionMiddleware': 620,
}

ROTATING_PROXY_LIST = [
    "http://user1:pass1@ip1:port1",
    "http://user2:pass2@ip2:port2",
    "http://user3:pass3@ip3:port3",
]

RETRY_TIMES = 5
RETRY_HTTP_CODES = [403, 429, 500, 502, 503, 504

# settings.py
DOWNLOADER_MIDDLEWARES = {
    'rotating_proxies.middlewares.RotatingProxyMiddleware': 610,
    'rotating_proxies.middlewares.BanDetectionMiddleware': 620,
}

ROTATING_PROXY_LIST = [
    "http://user1:pass1@ip1:port1",
    "http://user2:pass2@ip2:port2",
    "http://user3:pass3@ip3:port3",
]

RETRY_TIMES = 5
RETRY_HTTP_CODES = [403, 429, 500, 502, 503, 504

Your spider code doesn’t need to change. 

The middleware automatically handles proxy selection, rotation, and health monitoring.

Next steps


  • Test proxy behavior with your actual target websites.

  • Adjust concurrency, retries, and headers based on performance.

  • Add error handling and monitoring for production-scale scraping.

Support resources


Start building with stable, high-performance proxies today!

Share on

No credit card required. Request your free trial today.

Stay in the loop

Subscribe to our newsletter for the latest updates, product news, and more.

No spam. Unsubscribe at anytime.

What our clients are saying

What our clients are saying

What our clients are saying

Fast static residential IPs

Proxy plans

How many IPs do you need?
Choose your location: Ashburn, VA or Dallas, TX
Want to test first?Request a trial
Pro · 50 IPs in Ashburn$1.30 per IP
$65/month
Billed monthly
Every plan includes
  • Unlimited bandwidth*
  • Unlimited threads*
  • 10 Gbps network
  • 100% static ISP IPs
  • HTTP/HTTPS
  • Username:password auth
  • US locations, instant delivery
  • Support replies in 2–4 hours
3-day refund policy · cancel anytime
*Subject to our Acceptable Use Policy
How many IPs do you need?
Choose your location: Ashburn, VA or Dallas, TX
Want to test first?Request a trial
Pro · 50 IPs in Ashburn$1.30 per IP
$65/month
Billed monthly
Every plan includes
  • Unlimited bandwidth*
  • Unlimited threads*
  • 10 Gbps network
  • 100% static ISP IPs
  • HTTP/HTTPS
  • Username:password auth
  • US locations, instant delivery
  • Support replies in 2–4 hours
3-day refund policy · cancel anytime
*Subject to our Acceptable Use Policy
How many IPs do you need?
Choose your location: Ashburn, VA or Dallas, TX
Want to test first?Request a trial
Pro · 50 IPs in Ashburn$1.30 per IP
$65/month
Billed monthly
Every plan includes
  • Unlimited bandwidth*
  • Unlimited threads*
  • 10 Gbps network
  • 100% static ISP IPs
  • HTTP/HTTPS
  • Username:password auth
  • US locations, instant delivery
  • Support replies in 2–4 hours
3-day refund policy · cancel anytime
*Subject to our Acceptable Use Policy