Integrations / Framework
Use Proxys with Scrapy
Route a Scrapy spider through Proxys with the built-in proxy middleware.
Steps
- Make sure HttpProxyMiddleware is enabled (it is by default).
- Set meta['proxy'] on each request, or in start_requests.
- Use a session id per item if a site needs the same IP across pages.
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.