tanbopiao

pialuo —— 爬罗剔抉,刮垢磨光

Community tanbopiao
Updated

爬罗剔抉,刮垢磨光 —— 轻量化 Agent 网页抓取与清洗算子(独立重写,致谢 Crawl4AI)

pialuo —— 爬罗剔抉,刮垢磨光

轻量化网页抓取与内容提炼算子。抓取网页、按文本密度剪枝去噪,输出 LLM 友好的Markdown 或按 CSS 选择器 schema 提取结构化 JSON。

名字取自韩愈《进学解》:"爬罗剔抉,刮垢磨光"——爬罗(搜集)剔抉(挑选),正是"抓取→清洗→提炼"这件事。

纯 Python 标准库实现,零第三方依赖,单文件 666 行。

用法

# 抓取并输出清洗后的 Markdown
python pialuo.py https://www.python.org/

# 输出到文件,显示耗时与内存
python pialuo.py https://www.python.org/ --out page.md --profile

# 按 schema 提取结构化 JSON(无需 LLM)
python pialuo.py https://www.python.org/ --schema schema.json

schema 格式(JsonCss 风格):

{
  "baseSelector": "ul.menu li",
  "fields": [
    {"name": "title", "selector": "a", "type": "text"},
    {"name": "url", "selector": "a", "type": "attribute", "attribute": "href"}
  ]
}

选择器支持子集:tag、.class、#id、后代空格组合。

MCP 服务

仓库内 mcp_server.py 提供 JSON-RPC 2.0 over stdio 的 MCP 服务(零依赖),任何支持 MCP 的客户端可直接接入:

python mcp_server.py

工具:

  • fetch_page(url, timeout?, retries?, word_threshold?) —— 抓取网页并清洗为 LLM 友好 Markdown;
  • extract_structured(url, schema) —— 按 JsonCss 风格 schema 做结构化提取,无需 LLM。

与 Crawl4AI 的取舍对比

维度 Crawl4AI(上游) pialuo(本算子)
定位 全功能 Agent 爬取框架 单一算子:抓取→清洗→提取
代码形态 543 个 py 文件、约 15.6 万行 单文件 666 行
依赖 25+(Playwright、numpy、litellm 等) 0(纯标准库)
部署形态 Docker 镜像 8.2GB,要求 4GB RAM 一个 py 文件直接跑
空闲内存 538MB(实测) 进程 RSS 峰值约 25MB(含解释器基线),解析 51KB 页面 tracemalloc 峰值 0.78MB
51KB 页面处理耗时 — 解析+剪枝+渲染 78ms
抓取调度 asyncio 并发/重试/robots/缓存 同步抓取/重试/robots(缓存砍掉)
文本密度剪枝 PruningContentFilter 同思路自研:分词噪音匹配 + 词数阈值 + 链接密度
结构化提取 JsonCss/JsonXPath + LLM 策略 JsonCss 子集(LLM 策略砍掉)
浏览器/JS 执行 Playwright/patchright 双栈 无——动态渲染页面拿不到正文
Docker API 服务层 1211 行 server.py(上游漏洞聚集地) 无此层,攻击面不存在
CLI/Web UI/MCP/PDF/代理/深爬取 有 全部砍掉

功能对齐的核心场景:静态页抓取 → 去导航/页脚/广告 → LLM 友好 Markdown;CSS 选择器 schema → 结构化 JSON。实测 python.org 首页:新闻列表、成功故事、PSF 介绍等正文完整保留,导航/横幅/脚本剔除。

如实边界:需要 JS 渲染的页面(如 Bing 首页搜索结果)拿不到正文;无浏览器、无 JS 执行、无并发调度、无缓存、无代理轮换。

理念致谢

本项目功能、架构与逻辑思路致谢 Crawl4AI(Apache-2.0)。本仓库为独立重写,无任何上游代码血缘;依 Crawl4AI 许可证之Attribution Requirement,公开分发时注明出处如上。

复刻哲学

外来佳作功能、架构、逻辑皆可复刻,算子代码必自研完善;收编先深扫,复刻必致谢,轻量一个量级。

许可证

MIT(见 LICENSE)。

安装(PyPI)

pip install pialuo         # 算子本体 + MCP 入口 pialuo-mcp(stdio JSON-RPC 2.0)

命令行:pialuo <url>(--schema 结构化提取、--json、--no-robots 等);MCP 服务:pialuo-mcp。边界:无浏览器无 JS,动态渲染页拿不到正文。

MCP Client Configuration

Published on PyPI as pialuo. For MCP clients (Cline, Cherry Studio, Cursor, etc.):

{
  "mcpServers": {
    "pialuo": {
      "command": "uvx",
      "args": ["--from", "pialuo", "pialuo-mcp"]
    }
  }
}

MCP Server · Populars

MCP Server · New

    atilaahmettaner

    TradingMCP: Market Data & Technical Analysis for AI Assistants

    MCP server for market analysis in AI assistants: screeners, multi-timeframe technical analysis, backtests and sentiment for crypto, stocks, forex and futures. 39 tools. Self-host free, or use the hosted version, TradingMCP.

    Community atilaahmettaner
    lifan-builds

    Faster Mac Use (fmu)

    Background-first, multi-cursor browser and native macOS computer-use engine for AI agents

    Community lifan-builds
    agent360dev

    Agent360 Browser MCP

    The browser tool that can stop and ask you. A 2FA code, a CAPTCHA, a choice only you can make: it asks on your screen, then carries on in the same signed-in Chrome. 41 tools, MCP clients that run local servers, MIT.

    Community agent360dev
    robinAKL

    Agent Room

    Put Claude Code, Cursor, Codex, Gemini & Antigravity in one room — real-time multi-agent AI collaboration over MCP for distributed dev, code review, PR handoff & frontend↔backend integration. Free, self-hostable, MCP-native.

    Community robinAKL
    blen-labs

    Capture MCP

    AI-native Model Context Protocol (MCP) server that integrates SAM.gov, USASpending.gov, and Tango APIs to capture and analyze federal procurement and spending data through natural language queries. Responses include both human-readable text and structured JSON so MCP-compatible clients can consume the data programmatically.

    Community blen-labs