Skip to main content

MineWorker

PyPI Python CI License Docs

一个上手简单、结构清晰的 Python 爬虫框架,对标 feapder: 你只写 start_requests 和 parse,框架负责调度、下载、重试、去重、批量落库。

0.4.0 —— 单机(AirSpider)到分布式(Spider / TaskSpider / BatchSpider)全部可用。 变更见 CHANGELOG,后续规划见 Roadmap。

安装

pip install mineworker            # 核心
pip install "mineworker[all]"     # 含渲染 / MongoDB / MySQL / Redis / CLI / 指标

也可以按需装单项:render · mongo · mysql · redis · cli · metrics。

快速开始

pip install "mineworker[cli]"
mineworker create -p news_crawler
cd news_crawler && python main.py

或直接写:

import mineworker as mw


class NewsSpider(mw.AirSpider):
    def start_requests(self):
        yield mw.Request("https://news.ycombinator.com/", callback=self.parse)

    def parse(self, request, response):
        for a in response.css("span.titleline > a"):
            yield {"title": a.css("::text").get(), "url": a.css("::attr(href)").get()}


NewsSpider().start()

文档

完整文档:https://apersonw.github.io/mineworker/ (本地预览:pip install "mineworker[docs]" && mkdocs serve)

设计与实施计划见 IMPLEMENTATION_PLAN.md。

能力一览

运行时 单进程多线程、优先级队列、结束检测、Ctrl-C 优雅排空、崩溃 dump + retry 回放
网络 Request/Response(httpx + parsel)、自动重试、validate/failed_request 钩子、随机 UA、会话复用
分布式 Spider:Redis 队列 + 布隆去重 + 断点续爬 + 种子一次性锁 + 多节点心跳结束检测
任务驱动 TaskSpider 从任务源持续消费;BatchSpider 周期批次采集(任务表状态机 + 进度追踪 + 防丢)
数据 Item/UpdateItem、Pipeline(Console/CSV/MongoDB/MySQL upsert)、请求级 + Item 级去重(布隆/精确)
渲染 Request(render=True) —— Playwright 渲染池、wait_for/render_time/render_script
扩展 下载中间件链、代理池接口、账号 / Cookie 池(掉登录自动换号)
观测 Prometheus exporter、卡死/失败率告警(飞书/邮件)、debug=True
工具 mineworker create/shell/retry,create -i --table 读表结构反射生成 Item

开发

conda env create -f environment.yml && conda activate mineworker
pre-commit install
pytest && ruff check . && mypy

CI(GitHub Actions):ruff + mypy(strict) + pytest(Python 3.10–3.13)+ mkdocs build。

License

MIT

Release files for mineworker 0.4.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 mineworker 0.4.0
File Size Uploaded
mineworker-0.4.0.tar.gz 108.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mineworker 0.4.0
File Interpreter ABI Platform
mineworker-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 206.3 kB

Release files / mineworker-0.4.0.tar.gz

Download URL mineworker-0.4.0.tar.gz
Size 108.2 kB
Tags Source
SHA-256 checksum
How to use checksums
15d68db28aa21fa5e3d91605e5df0494af4faf02473d34fc7f46272372df8d05
BLAKE2b-256 checksum
How to use checksums
a624586026c296db4a4974129f1d307f9d23a2b01f205ec73a0d6a1e21bdeac9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / mineworker-0.4.0-py3-none-any.whl

Download URL mineworker-0.4.0-py3-none-any.whl
Size 98.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
685ec38d864cc7dbc896c2544d3e492d474982dbace9503cef7e04f9e2b8a7c6
BLAKE2b-256 checksum
How to use checksums
c6bf2f4590f9cac3b4b1f442c025824fa059fe22ca0c27788cd12974933e3607
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log
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