Scrapy Proxy Middleware

A quick guide on how to set up proxies on Scrapy Proxy Middleware.

  1. Open the Terminal window.
  2. Navigate to the main directory of your project folder using cd yourprojectname.
  3. Download our proxy middleware using the following command:
curl https://raw.githubusercontent.com/Smartproxy/Scrapy-Middleware/master/smartproxy_auth.py > smartproxy_auth.py
1324

Scrapy Proxy Middleware – Download

  1. You should now see that your project folder contains the smartproxy_auth.py file.
  2. Using a file manager, navigate to your project folder, where you should see the settings.py file.
  3. Edit the settings.py file using an editor of your choice.
595

Scrapy Proxy Middleware – Edit settings.py

  1. Add the following properties at the bottom:
DOWNLOADER_MIDDLEWARES = {
    'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 110,
    'yourprojectname.smartproxy_auth.ProxyMiddleware': 100,
}

SMARTPROXY_USER = 'username' ## Smartproxy Username (Sub-user)
SMARTPROXY_PASSWORD = 'password' ## Password for your user
SMARTPROXY_ENDPOINT = 'gate.smartproxy.com' ## Endpoint you'd like to use
SMARTPROXY_PORT = '7000' ## Port of the endpoint you are using.
475

Scrapy Proxy Middleware – Proxy settings

  1. In the DOWNLOADER_MIDDLEWARES section, change the yourprojectname line to the name of your project.
744

Scrapy Proxy Middleware – Change project name

  1. Make sure that you enter your account details as well as proxy details within punctuation marks ' '.
  2. Finally, Save the file.

📘

To find more information about the setup, make sure to visit our Github Page. In case you wish to use Smartproxy directly in your request, please refer to this article.