爬虫工具包,写爬虫更快!!!
Project description
一个高效的 Python 爬虫工具库,提供解析、文本标准化等常用功能,助力快速开发爬虫项目。
安装
使用 pip 安装:
pip install sd_spider_utils
Scrapy 中间件按需安装:
pip install "sd_spider_utils[all]"
只使用某一个下载后端时,也可以安装 scrapy、requests-go、 drissionpage 或 scrapling extra。Scrapling 首次使用还需要执行:
scrapling install
使用示例
from sd_spider_utils.text_utils import normalize_text text = "Café['S.\u2009M. Koksbang\xa0', 'S.\u2009M. Koksbang']" # 包含全角字符和组合字符 clean_text = normalize_text(text) print(clean_text)
Scrapy 下载中间件
推荐只注册统一路由中间件:
DOWNLOADER_MIDDLEWARES = {
"sd_spider_utils.middlewares.BackendRouterMiddleware": 950,
}
yield scrapy.Request(
url,
meta={"download_backend": "requests_go"},
)
可选后端为 scrapy、requests_go、dp、 dp_listen 和 scrapling。
监听接口时使用 download_backend="dp_listen",并通过 listen_path 设置需要等待的接口路径。
静态代理可在路由中间件之前注册:
DOWNLOADER_MIDDLEWARES = {
"sd_spider_utils.middlewares.TunnelProxyMiddleware": 740,
"sd_spider_utils.middlewares.BackendRouterMiddleware": 950,
}
SD_PROXY_URL = "http://127.0.0.1:7890"
只有 request.meta["use_proxy"] 为真时才会补充 SD_PROXY_URL; 请求里已有 proxy 时不会覆盖。
功能特性
HTML 解析:快速提取网页中的文本内容。
文本标准化:清洗和规范化抓取到的文本数据。
常用工具函数:提供日期提取、数据转换和多种下载后端。
项目链接
许可证
MIT License,详见 LICENSE 文件。
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sd_spider_utils-1.0.7.tar.gz.
File metadata
- Download URL: sd_spider_utils-1.0.7.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e13c236e2d591eb9332244d23e39ab45ddff0d3035c03a516824b11b51d6359c
|
|
| MD5 |
e8023cea4e78b0d320f95ba7728e6222
|
|
| BLAKE2b-256 |
f487fc32bc97fa0f58c91d733d4828e3514e177ea9fdf024abc8524352e23bf8
|
Provenance
The following attestation bundles were made for sd_spider_utils-1.0.7.tar.gz:
Publisher:
publish.yml on StarDreamTech/sd-spider-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sd_spider_utils-1.0.7.tar.gz -
Subject digest:
e13c236e2d591eb9332244d23e39ab45ddff0d3035c03a516824b11b51d6359c - Sigstore transparency entry: 2032272914
- Sigstore integration time:
-
Permalink:
StarDreamTech/sd-spider-utils@5ee0629dd91163902bf7571b0c656f9e10054343 -
Branch / Tag:
refs/tags/v1.0.7 - Owner: https://github.com/StarDreamTech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5ee0629dd91163902bf7571b0c656f9e10054343 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sd_spider_utils-1.0.7-py3-none-any.whl.
File metadata
- Download URL: sd_spider_utils-1.0.7-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89118a9f3c5591494ef142f4a2daac1eadd42223d09847f1573f2d2b359af025
|
|
| MD5 |
9354dbe77a98ef9fb72f1a0170c57ccc
|
|
| BLAKE2b-256 |
b30723ad9244bc622adca7abec418dae570caa7dd91d3e4926a4b8252f725dcf
|
Provenance
The following attestation bundles were made for sd_spider_utils-1.0.7-py3-none-any.whl:
Publisher:
publish.yml on StarDreamTech/sd-spider-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sd_spider_utils-1.0.7-py3-none-any.whl -
Subject digest:
89118a9f3c5591494ef142f4a2daac1eadd42223d09847f1573f2d2b359af025 - Sigstore transparency entry: 2032273142
- Sigstore integration time:
-
Permalink:
StarDreamTech/sd-spider-utils@5ee0629dd91163902bf7571b0c656f9e10054343 -
Branch / Tag:
refs/tags/v1.0.7 - Owner: https://github.com/StarDreamTech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5ee0629dd91163902bf7571b0c656f9e10054343 -
Trigger Event:
push
-
Statement type: