Integrations / Framework

Use Proxys with Scrapy

Route a Scrapy spider through Proxys with the built-in proxy middleware.

Steps

  1. Make sure HttpProxyMiddleware is enabled (it is by default).
  2. Set meta['proxy'] on each request, or in start_requests.
  3. Use a session id per item if a site needs the same IP across pages.
Python
import scrapy

PROXY = "http://USERNAME-country-us:PASSWORD@gw.proxys.co:8000"

class Prices(scrapy.Spider):
    name = "prices"
    def start_requests(self):
        yield scrapy.Request("https://example.com", meta={"proxy": PROXY})
    def parse(self, response):
        yield {"title": response.css("title::text").get()}

Before you start

Replace USERNAME and PASSWORD with a sub-user's credentials from the dashboard. Change -country-us to the country you need, or remove it for a random location. See targeting options for city, ASN and sticky sessions.

Try 1 GB for $1