基础工具与工作流 · daymade/claude-code-skills

scrapling-skill

Install, troubleshoot, and use Scrapling CLI to extract HTML, Markdown, or text from webpages. Use this skill whenever the user mentions Scrapling, `uv tool install scrapling`, `scrapling extract`, WeChat/mp.weixin articles, browser-backed page fetching, or needs help deciding between static and dynamic extraction.

L5 严管 · 隔离环境与严格审计V2 已复核条款/合规执行命令联网读写文件Dual-pass Audit
Author daymadeGitHub daymade/claude-code-skills ↗Stars 1392License MIT(仓库根 LICENSE,Copyright (c) 2025 daymade;GitHub API spdx MIT)Commit d5c4678cb5
管控等级描述 skill 的能力与建议配套的管控措施,不代表质量或安全认证,也不表示可用或不可用。是否使用由用户和管理者决定。不同 agent 宿主对权限的约束各不相同,请勿假定宿主一定会提供安全兜底。第三方 skill 版权归原作者,使用风险由使用者自行承担。

1实现原理 · 为什么它能做到

它自己不实现抓取:全部能力是把外部 CLI「scrapling」用正确姿势调起来。skill 的实质是「安装诊断 + 抓取档位选择 + 输出验收」三段 SOP,抓取引擎完全在外包工具里。

scrapling-skill/SKILL.md
Use Scrapling through its CLI as the default path. Start with the smallest working command, validate the saved output, and only escalate to browser-backed fetching when the static fetch does not contain the real page content.
这是「为什么能实现宣称功能」的根答案:能力来自 scrapling 这个独立开源包,本 skill 提供的是判断力与失败恢复路径。

先诊断后使用是硬前置:skill 把「用户的安装可能是坏的」当作默认假设,要求先跑自带诊断脚本,并以其输出为下一步的唯一依据。

scrapling-skill/SKILL.md
Run the bundled diagnostic script first: ```bash python3 scripts/diagnose_scrapling.py ``` Use the result as the source of truth for the next step.
配套:'Do not assume the user's Scrapling install is healthy. Verify it first.'

诊断脚本用 shutil.which + `scrapling --help` 的真实退出码与 stderr 关键字('no module named click' / 'install scrapling with any of the extras')区分「没装」与「装了但缺 CLI extras」,并直接给出对应的修复命令。

scrapling-skill/scripts/diagnose_scrapling.py
print("status: broken") if "install scrapling with any of the extras" in output.lower() or "no module named 'click'" in output.lower(): print("cause: installed without CLI extras") print("fix: `uv tool uninstall scrapling` then `uv tool install 'scrapling[shell]'`")
docstring 自述:'Diagnose a local Scrapling CLI installation and optionally run a smoke test.' 全部外部调用走 subprocess 参数列表,无 shell=True。

抓取强度是三级阶梯(静态 get → 浏览器 fetch → 反检测 stealthy-fetch),且被明确要求「不要默认用最强档」——这是该 skill 相对普通「调 CLI」文档的核心方法论。

scrapling-skill/SKILL.md
- Start with `extract get` for normal pages, article pages, and most WeChat public articles. - Use `extract fetch` when the static HTML does not contain the real content or the page depends on JavaScript rendering. - Use `extract stealthy-fetch` only after `fetch` still fails because of anti-bot or challenge behavior. Do not make it the default.
stealthy-fetch 是反反爬/绕过检测能力的一等公民入口——安全分档的关键依据之一。

输出验收被写成硬纪律:不准凭退出码宣布成功,必须打开落盘文件看大小与内容。这是把「假成功」当主要失败模式来防。

scrapling-skill/SKILL.md
- Do not claim success from exit code alone. Inspect the saved file.
配套命令:'wc -c article.md' 与 "sed -n '1,40p' article.md"、'rg -n '<title>|js_content|rich_media_title|main' page.html'。

对 TLS 证书验证失败给出「关闭校验」的恢复配方(--no-verify),但附加了「必须先确认失败匹配 curl:(60) 模式」和「不得默认关闭」两道口头前置。

scrapling-skill/SKILL.md
If `extract get` fails with `curl: (60) SSL certificate problem`, treat it as a local trust-store problem first, not a Scrapling content failure. Retry the same command with: ```bash --no-verify ``` Only do this after confirming the failure matches the local certificate verification error pattern. Do not silently disable verification by default.
同一条配方在 references/troubleshooting.md 的 'Verified Failure Modes → 3. Static fetch TLS trust-store failure' 里重复出现;且 SKILL.md 的「微信文章冒烟」示例命令直接带着 --no-verify(见 security.injection_surface)。

2核心能力

01安装体检:区分未安装 / 缺 CLI extras / 浏览器运行时缺失
02浏览器运行时探测(Playwright 的 chromium 与 chrome-headless-shell 缓存)
03可复现冒烟测试:按需跑静态/动态抓取并把结果文件落到临时目录、打印大小与预览
04微信公众号正文定向抓取(#js_content 选择器模式)
05HTML / Markdown / 文本三形态导出(含 -s 主内容选择器)
06已验证失败模式库(3 类:缺 extras / 浏览器未就绪 / TLS 信任库问题)+ 恢复路径
07反反爬升级通道(stealthy-fetch)作为受控的最后一档
08防幻觉纪律包(不许盲装、不许拿退出码当成功、不许硬编码个人绝对路径)

3外部依赖

KindDependency / Endpoint
cliscrapling(外部开源抓取 CLI;本 skill 的核心依赖,未随包分发)
cliuv(工具安装器)
clipython3(运行自带诊断脚本)
clirg / wc / sed(输出验收用,均为常规 POSIX 工具)
packagePlaywright 浏览器运行时(由 `scrapling install` 下载,落 ~/Library/Caches/ms-playwright 或 ~/.cache/ms-playwright)
network任意目标站点(用户给定的 URL;skill 不限定域名,示例用 example.com 与 mp.weixin.qq.com)
networkexample.com(文档中的占位目标,非固定端点)

4管控建议与判定依据

建议配套管控措施
面向 Agent
隔离环境,逐次授权
面向管理者
严格授权、全量审计、合规确认
判定依据(文件路径与关键语句摘要)
  • SKILL.md / 脚本参数: 包含绕过自动化检测、关闭宿主沙箱或跳过 SSL 证书校验
  • scripts/: 执行本地脚本或命令: python3 scripts/diagnose_scrapling.py [--url U] [--selector S] [--dynamic]
  • 网络端点: 声明外部网络访问: 由 scrapling CLI 对用户给定的任意 URL 发起 HTTP 抓取(静态 get 或浏览器 fetch);本 skill 脚本自身不发网络
  • 本地工作目录: 文件读写与工件输出: 抓取产物落盘到用户指定路径(示例:page.html / article.md)
审计说明: 。判红属「策略/能力级」而非「恶意植入级」——代码层面很干净:全目录仅 3 个文件,诊断脚本纯标准库、subprocess 走参数列表无 shell=True、无凭证读取、无硬编码外发端点、无混淆内容。判红是两条被文档当作正规路径教导的能力:①【安全降级】TLS 校验关闭。references/troubleshooting.md 的 '3. Static fetch TLS trust-store failure' 与 SKILL.md 的对应小节都把 `--no-verify` 写成恢复配方,更关键的是 SKILL.md 的『Diagnose and smoke test a WeChat article body』示例命令本身就把 `--no-verify` 与 `--selector '#js_content'` 并列写成一条可直接复制的命令;两道『先确认 curl:(60) 模式』『不要默认关闭』的口头前置只活在文字里,无法被强制执行。②【反反爬/绕过】stealthy-fetch 被明确定位为 anti-bot / challenge 场景的升级通道(Step 3 与 Step 6 各写一次),即规避站点反爬检测作为一等公民入档。叠加『任意 URL 抓取 + 微信公众号正文定向抓取』的组合面,按分级范式落入红档。缓解因素须一并说明:stealthy-fetch 被要求「不要做默认档」,--no-verify 被要求「只在匹配特定错误时才用」,且该 skill 无任何回传通道(抓到的内容只落本地)。因此红档读作『能力与指导足够强,使用前请知情』,不是『疑似恶意』。

5第二遍独立确认

  • [ok] 每条外部依赖的调用点是否真实存在(而非推测) — 六条依赖全部回到原文:scrapling(Step 2 的 uv tool install 'scrapling[shell]'、Step 4 的 scrapling extract …)、uv(同处)、python3(Step 1 的 python3 scripts/diagnose_scrapling.py)、Playwright 运行时(Step 2 的 scrapling install + 诊断脚本的 ms-playwright 缓存探测代码)、mp.weixin.qq.com(Step 4 的公众号示例)、example.com(Step 4 占位示例)。无推测项。
  • [ok] 代码层面是否存在被遗漏的网络/凭证行为(找反例) — 反例检索失败:diagnose_scrapling.py 的 import 仅 argparse/shutil/subprocess/sys/tempfile/pathlib/typing;无 urllib/requests/socket;无环境变量或 token 读取(grep os.environ/getenv 零命中);唯一的网络行为全在被调用的 scrapling CLI 里,本仓库不自带该 CLI。故『脚本自身不发网络请求、不读凭证』成立。
  • [ok] 『外部 CLI 才是能力本体』这一实现原理是否夸大——skill 自身是否另有抓取实现 — 三文件全部读毕:诊断脚本只做 which/--help/缓存目录探测与一次可选 subprocess 冒烟;troubleshooting.md 全是命令与症状;SKILL.md 全是 SOP。无任何自研抓取/解析代码,原理陈述成立且不夸大。
  • [discrepancy] 安全降级(--no-verify)是否只出现在文档说明、未进入可执行示例 — 第一遍按上一条思路复核后发现更强的事实:SKILL.md 的『### Diagnose and smoke test a WeChat article body』代码块是把 --no-verify 与 --selector '#js_content' 写在一起的三行命令(python3 scripts/diagnose_scrapling.py \ --url 'https://mp.weixin.qq.com/s/ARTICLE_ID?scene=1' \ --selector '#js_content' \ --no-verify),而诊断脚本确实会把它透传:`if args.no_verify: cmd.append("--no-verify")`。即降级路径不仅被说明、还被脚本实现并示范,不是纯叙述。
  • [ok] references/troubleshooting.md 与 SKILL.md 是否一致 — 三档抓取顺序(get → fetch → stealthy-fetch)、--no-verify 的限定条件、浏览器缓存两处路径、微信抓取模式在三档文档中表述一致;troubleshooting.md 额外给出 Contents 与更细的症状清单,属补充而非冲突。
  • [discrepancy] 本 pin 下目录内容与历史(含 .security-scan-passed 标记)是否变化 — git diff 63a65c1fccae9f32f7d1e0e99670321ae09d4f53..HEAD -- scrapling-skill/ 显示唯一变化是删除 scrapling-skill/.security-scan-passed('1 file changed, 4 deletions(-)'),三个实质文件字节未变。该标记文件是 gitleaks 类密钥扫描的通过记录,与本 skill 的能力/风险结论无关,但意味着『曾有过的安全扫描通过标记在当前 pin 已不存在』,引用旧记录时不应再把它算作现状。另:同 pin 的 data/analysis 目录内已有一份本 skill 的旧侦查记录(commit 63a65c1…),本次为按新 pin 的独立重做,结论方向一致(均判红)而证据面按当前 pin 重新采集。
  • [ok] pin commit 与 skill.path 是否与任务书一致 — git rev-parse HEAD = d5c4678cb5d4fd6acc9c922690df035dbd33d247;该目录位于仓库根,相对路径 scrapling-skill;本目录最后实质提交 878f947(2026-09-07)。GitHub API 复核 MIT / stars 1392 / pushed 2026-09-15T09:30:04Z。

6结论

  • 把「先验证环境」变成流程第一步并给出机器可读判定,避免最常见的假失败(把缺 CLI extras 当成目标站点抓不到)。
  • 档位阶梯(get → fetch → stealthy-fetch)提供了可解释的成本/收益决策规则,而不是「抓不到就上浏览器」。
  • 输出验收纪律具体可执行(wc -c / sed 预览 / rg 找关键容器),直接针对「退出码 0 但内容是空壳」这一抓取类任务的头号幻觉。
  • 公众号文章抓取有明确的默认选择器与验证点,把一类高频具体任务沉淀成了可复用配方。
  • 适合: 适合:需要把网页内容稳定取回本地的日常任务,尤其是微信公众号文章正文归档、需要判断『静态抓不到才上浏览器』的场景,以及刚装好 scrapling 但不确认是否装对的人(诊断脚本是一行命令)。也适合把它当作『如何正确使用外部抓取 CLI』的范例学习——它的验收纪律值得照抄。
    不适合: 不适合:需要合规审查的采集任务(skill 不判断站点授权,且提供反爬升级档);需要抓取需登录/付费墙内容的场景(scrapling 的能力边界与站点授权不在本 skill 讨论范围);期望 skill 自带抓取引擎的环境(它必须外装 scrapling + Playwright 运行时);对 TLS 校验有硬性要求的场景(文档准备了关闭校验的路径)。
    Install Agent-Ready
    ① Verified Mirror 2026-09-15
    Option A · Direct DownloadDownload scrapling-skill.tar.gz
    sha256: 65c575aca652cc60…
    Option B · Copy Guide for Agent
    install.json
    agent 读 JSON 指南后会自动从本站下载安装,无需更多说明。
    ② Upstream GitHub
    GitHub Repo ↗
    Pinned to commit d5c4678cb5.