Skip to content

Smartproxy/Scrapy-Middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

🏠 Main Repository 🏠

Disclaimer

In case you are not aware of what Scrapy is or how it works, we suggest researching Scrapy documentation in order to continue development with this tool.

Prerequisites

To get started with Scrapy you will first need to install it using methods provided in their documentation. Check here for more information

Installation

Once you get Scrapy up and running if you have not yet, make sure that you create your project folder:

scrapy startproject yourprojectname

scrapy startproject anaconda prompt

When project directory is setup, you can deploy our 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
  4. You should now see your project folder populated with smartproxy_auth.py file.

Configuration

To start using our middleware for proxy authentication, you'll need to configure settings for our proxy authentication.

Doing so is very simple:

  1. Using file manager, navigate to your project folder, you should see settings.py file located at the bottom of the directory.
  2. Edit the settings.py file using an editor of your choice and 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.

smartproxy scrapy middleware http proxy configuration with username password authentication

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

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

Once all that is done, all of your spiders will be going through our proxies, if you are not sure how to setup a spider, take a look here

Need help?

Email - sales@smartproxy.com
Live chat 24/7