Metadata-Version: 2.4
Name: sd_spider_utils
Version: 1.0.7
Summary: 爬虫工具包，写爬虫更快！！！
Author-email: 星梦 <cpython666@gmail.com>
License: MIT License
        
        Copyright (c) 2025 星梦
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://space.bilibili.com/1909782963
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Natural Language :: Chinese (Simplified)
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: beautifulsoup4<5,>=4.12
Provides-Extra: excel
Requires-Dist: pandas<3,>=2; extra == "excel"
Requires-Dist: openpyxl<4,>=3.1; extra == "excel"
Provides-Extra: xpath
Requires-Dist: lxml<7,>=4.9; extra == "xpath"
Provides-Extra: scrapy
Requires-Dist: Scrapy<3,>=2.16; extra == "scrapy"
Provides-Extra: drissionpage
Requires-Dist: Scrapy<3,>=2.16; extra == "drissionpage"
Requires-Dist: DrissionPage<5,>=4.1.1.4; extra == "drissionpage"
Provides-Extra: requests-go
Requires-Dist: Scrapy<3,>=2.16; extra == "requests-go"
Requires-Dist: requests-go<2,>=1.0.9; extra == "requests-go"
Provides-Extra: scrapling
Requires-Dist: Scrapy<3,>=2.16; extra == "scrapling"
Requires-Dist: scrapling[fetchers]<0.5,>=0.4.9; extra == "scrapling"
Provides-Extra: all
Requires-Dist: pandas<3,>=2; extra == "all"
Requires-Dist: openpyxl<4,>=3.1; extra == "all"
Requires-Dist: lxml<7,>=4.9; extra == "all"
Requires-Dist: Scrapy<3,>=2.16; extra == "all"
Requires-Dist: DrissionPage<5,>=4.1.1.4; extra == "all"
Requires-Dist: requests-go<2,>=1.0.9; extra == "all"
Requires-Dist: scrapling[fetchers]<0.5,>=0.4.9; extra == "all"
Dynamic: license-file

sd_spider_utils
================

一个高效的 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 = "Ｃａｆé['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 解析**：快速提取网页中的文本内容。
- **文本标准化**：清洗和规范化抓取到的文本数据。
- **常用工具函数**：提供日期提取、数据转换和多种下载后端。

项目链接
--------

- PyPI: https://pypi.org/project/sd_spider_utils/
- 源码仓库: https://github.com/StarDreamTech/sd_spider_utils
- 视频教程:  https://space.bilibili.com/1909782963
- 作者: 星梦 (cpython666@gmail.com)

许可证
------

MIT License，详见 LICENSE 文件。
