Skip to main content

A module to wrap PProxy and allow more proxy options in Scrapy

Project description

ScrapyProxyCompat

Introduction

ScrapyProxyCompat is a Python module that wraps pproxy to allow a greater range of proxy types to be used with Scrapy. It supports any type of remote connection that is supported by pproxy. This module should be used with a rotating proxy middleware such as scrapy-rotating-proxy. ScrapyProxyCompat should be started before Scrapy and should be allowed to run in the background while Scrapy is crawling. The middleware that you write or choose to use must accept a file input made up of one proxy server per line if you would like to use the writeProxies(filePath) method. For example:

http://127.0.0.1:2000
http://127.0.0.1:2001
http://127.0.0.1:2002

Installation

To install ScrapyProxyCompat run pip install ScrapyProxyCompat

Usage

To begin using ScrapyProxyCompat, create an instance of the ScrapyProxyController class.

from ScrapyProxyCompat.ScrapyProxyCompat import ScrapyProxyController

# Usage: ScrapyProxyController(retry_time:float=300.0, retry_count: int=5, proxies:list=[], starting_port:int=2000)
# Where:
# retry_time is optional, the amount of time in seconds to wait before retrying a pproxy connection that has exited
# retry_count is optional, the number of times to retry establishing a pproxy connection before allowing the Thread to die
# proxies is an optional list of proxies following the normal PProxy syntax: [http, socks, ss, ssl, secure (Or a combination of these)]://ip_address:port#username:password
# starting_port is an optional valid port number to be used as the starting local port. You should expect it to use this port +1 for each proxy
controller = ScrapyProxyController(500.0, 10, ["http+ssl://proxyip.com:2323#Good:Creds", "socks5://proxyip.com:2323#Good:Creds"], 3000)

If you provided a proxy list when creating the ScrapyProxyController, you can now start your proxies.

controller.startProxies()

If you did not provide a proxy list when creating the ScrapyProxyController, you must read your proxies from a text file made up of one proxy server per line. This function may also be used to overwrite the passed proxies before the proxies have been started.

# Usage: ScrapyProxyController.readProxies(filePath)
# Where:
# filePath is the String path to the file you want to read
controller.readProxies("/path/to/remote/proxies/file.txt")

Once you have started your proxies, you can get a list of all proxy Threads with getProxies() or get a list of all local proxy addresses with getProxyAddresses(). You can also write the proxies to a file. Typically this will be a Scrapy proxy file.

# Usage: ScrapyProxyController.writeProxies(filePath)
# Where:
# filePath is the String path to the file you want to write
controller.writeProxies("/path/to/scrapy/proxies/file.txt")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ScrapyProxyCompat-0.1.4.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ScrapyProxyCompat-0.1.4-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file ScrapyProxyCompat-0.1.4.tar.gz.

File metadata

  • Download URL: ScrapyProxyCompat-0.1.4.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for ScrapyProxyCompat-0.1.4.tar.gz
Algorithm Hash digest
SHA256 04cdcab8d5a4923586aaff58a7cabe30716e7cd1d0a31d9a9d5f78dc16f23add
MD5 ad88cf4c885b9246b293e5b1b5171036
BLAKE2b-256 445703f058207fd89fa3769772452de5b51b0a1224f49dc760361326374b0b03

See more details on using hashes here.

File details

Details for the file ScrapyProxyCompat-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: ScrapyProxyCompat-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for ScrapyProxyCompat-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e31120f35819e649a02fe9e4f7e5221def5f419768511cd43fb8f39c92af1484
MD5 dbf8328032ddfc59dee55c08fbb0508c
BLAKE2b-256 cbd5952b0ef8f0ebb51f93cc58128e55d08223c1b9260e43cae129796529ebe4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page