Metadata-Version: 2.1
Name: spider-brew-kit
Version: 0.1.6
Summary: 
Home-page: https://spider-brew-kit.readthedocs.io/en/latest/
License: Apache-2.0
Keywords: spider,scrapy,spider-tool-kit,spider-kit,spider-tools,spider-tool-kit
Author: Pony.Ma
Author-email: mtf201013@gmail.com
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: redis (>=4.6.0)
Requires-Dist: scrapy (>=2.7.0,<3.0.0)
Requires-Dist: scrapy-playwright (>=0.0.26,<0.0.27)
Project-URL: Documentation, https://spider-brew-kit.readthedocs.io/en/latest/
Project-URL: Repository, https://github.com/ma-pony/spider-tool-kit
Description-Content-Type: text/markdown

# spider-brew-kit

A library for scrapy tools, including but not limited to the usual pipelines, middlewares, etc.

## install

```shell
pip install spider-brew-kit
```

## usage

### pipelines

#### mongo pipeline

A pipeline saved into MongoDB asynchronously with txmongo

use database
db.createUser(
{
user: "username",
pwd: "password",
roles: [ { role: "readWrite", db: "database" } ]
}
)

how use:

1. add to settings.py

```python
ITEM_PIPELINES = {
    'scrapy_kit.pipelines.MongoPipeline': 300,
}
```

2. add mongo config to settings.py

```python
MONGO_URI = "mongodb://username:password@host:port"
MONGO_DATABASE_NAME = "database"
MONGO_COLLECTION_NAME = "collection"
```

### middlewares

#### proxy connection close middleware

Proxy close connection multiplexing middleware

Tunnel Proxy Dynamic Edition request found that the number of requests in the Personal Centre Tunnel Proxy Usage
Statistics is very small, which is seriously inconsistent with the real number of requests.
Moreover, there is no IP change when using Tunnel Broker Dynamic Edition.
The reason for this is that the tunnel sends requests that reuse previously established connections.
You need to add Connection: close to the header.

How to use it:

1. Add in settings.py:

```python
DOWNLOADER_MIDDLEWARES = {
    'scrapy_kit.middlewares.ProxyConnectionCloseMiddleware': 543,
}

```

## development

```shell
git clone
cd spider-brew-kit
poetry install
```

