Skip to main content

爬虫工具包,写爬虫更快!!!

Project description

一个高效的 Python 爬虫工具库,提供解析、文本标准化等常用功能,助力快速开发爬虫项目。

安装

使用 pip 安装:

pip install sd_spider_utils

Scrapy 中间件按需安装:

pip install "sd_spider_utils[all]"

只使用某一个下载后端时,也可以安装 scrapyrequests-godrissionpagescrapling 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"},
)

可选后端为 scrapyrequests_godpdp_listenscrapling

监听接口时使用 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

sd_spider_utils-1.0.7.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

sd_spider_utils-1.0.7-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

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

Hashes for sd_spider_utils-1.0.7.tar.gz
Algorithm Hash digest
SHA256 e13c236e2d591eb9332244d23e39ab45ddff0d3035c03a516824b11b51d6359c
MD5 e8023cea4e78b0d320f95ba7728e6222
BLAKE2b-256 f487fc32bc97fa0f58c91d733d4828e3514e177ea9fdf024abc8524352e23bf8

See more details on using hashes here.

Provenance

The following attestation bundles were made for sd_spider_utils-1.0.7.tar.gz:

Publisher: publish.yml on StarDreamTech/sd-spider-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sd_spider_utils-1.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for sd_spider_utils-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 89118a9f3c5591494ef142f4a2daac1eadd42223d09847f1573f2d2b359af025
MD5 9354dbe77a98ef9fb72f1a0170c57ccc
BLAKE2b-256 b30723ad9244bc622adca7abec418dae570caa7dd91d3e4926a4b8252f725dcf

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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