Skip to main content

Подключение ротации прокси-серверов к проекту на scrapy

Подключение выполняется в Downloader Middleware.

Чтобы его подключить, надо

  1. Инсталлировать

    pipenv run python -m pip install -e git+https://github.com/gendobr/scrapyproxy.git/#egg=bwt_scrapy_proxy
    

    или

    pip install -e git+https://github.com/gendobr/scrapyproxy.git/#egg=bwt_scrapy_proxy
    
  2. в settings.py в словарь DOWNLOADER_MIDDLEWARES добавить

    'bwt_scrapy_proxy.ProxyRotationMiddleware':530
    
  3. в settings.py добавить параметры

       X_BWT_PROXY_MEDIATOR = "http://192.168.11.82:5001"
       X_BWT_PARSERNAME = "test"
    

    Сейчас mitmproxy работает на 192.168.11.82 и слушает порт 5001

    X_BWT_PARSERNAME = "test" - уникальный идентификатор парсера

  4. в базу данных (таблица parsers) внести уникальный идентификатор парсера (параметр X_BWT_PARSERNAME из settings.py) и максимальное количество коннектов (parsers.threads_limit) Это делает админ БД парсеров.

Metadata

Release files for bwt-scrapy-proxy 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bwt-scrapy-proxy 0.1.0
File Size Uploaded
bwt_scrapy_proxy-0.1.0.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bwt-scrapy-proxy 0.1.0
File Interpreter ABI Platform
bwt_scrapy_proxy-0.1.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 8.2 kB

Release files / bwt_scrapy_proxy-0.1.0.tar.gz

Download URL bwt_scrapy_proxy-0.1.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
99a766a1d7f546e71ea73322e73db3470a58c25bdc79c417761246e7a73954a4
BLAKE2b-256 checksum
How to use checksums
c27951284308fac882ef651345b2cd991992fb0094e5769c401bc796529234c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

Release files / bwt_scrapy_proxy-0.1.0-py2.py3-none-any.whl

Download URL bwt_scrapy_proxy-0.1.0-py2.py3-none-any.whl
Size 3.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
20e0866e3faf447d21cbe7c5ff203fa10b8c34eb6413b91873ed9f997e11f688
BLAKE2b-256 checksum
How to use checksums
4ee1e4a63927dab0d9262673bcda6ae05cecec9014f7842bcb8c0c45f10282e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page