Scrapy Proxy Middleware

A quick guide to setup proxies on Scrapy Proxy Middleware.

  1. Open 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
Scrapy proxy middleware downloadScrapy proxy middleware download

Scrapy proxy middleware download

  1. You should now see that your Project Folder is filled with the smartproxy_auth.py file.

  2. Using a File Manager, navigate to your Project Folder, where you should see the settings.py  file which is located at the bottom of the directory.

  3. Edit the settings.py file using an editor of your choice.

Scrapy proxy middleware edit settings.pyScrapy proxy middleware edit settings.py

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.
Scrapy proxy middleware proxy settingsScrapy proxy middleware proxy settings

Scrapy proxy middleware proxy settings

  1. In the DOWNLOADER_MIDDLEWARES change yourprojectname line to the name of your project.
Scrapy proxy middleware change project nameScrapy proxy middleware change project name

Scrapy proxy middleware change project name

  1. Make sure that you enter your account details as well as proxy details within punctuation marks ('').

  2. 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 instead.