trafilatura

Trafilatura:一个用于从网络收集文本的 Python 包与命令行工具,负责网页爬取、下载并从原始 HTML 中提取主要内容、元数据和评论,输出为 CSV、JSON、Markdown、XML 或 TXT 等结构化格式。

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "trafilatura":https://skillpi.com/zh/skills/deepskill-88edec0893fa1dcfcf25ae998ce89509eec6054352c3937ea041efc806af2236。安装前核对上游来源和版本:https://skillhub.cn/skills/user_3c6cb52e/trafilatura-web-text-extraction-crawling。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

skillhub.cn

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

Trafilatura:一个用于从网络收集文本的 Python 包与命令行工具,负责网页爬取、下载并从原始 HTML 中提取主要内容、元数据和评论,输出为 CSV、JSON、Markdown、XML 或 TXT 等结构化格式。

0 下载

介绍来源: third_party · user_3c6cb52e · 1.0.0 参考来源

SkillPi 解读

实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: trafilatura
description: >-
  Extract clean article text and metadata from URLs or HTML with trafilatura
  CLI. Use for single-page extraction, piped/local HTML, bounded discovery.
  NOT for research synthesis (research), PDFs (docling), raw fetch (fetch), video (yt-dlp).
argument-hint: "<extract|pipe|discover|batch|local|metadata|archived|doctor|help> [target]"
user-invocable: true
license: MIT
metadata:
  author: wyattowalsh
  version: "1.0.0"
allowed-tools: Bash Read Glob Write

Trafilatura

CLI skill for trafilatura: extract main article text and metadata from URLs, piped HTML, or local files. Follow the stdout-first protocol before any batch writes.

Scope: Single-page extraction, metadata JSON, piped/local HTML, bounded URL discovery (--list), and user-approved batch processing. NOT for: multi-source research (research), PDF/tables (docling), raw page fetch (fetch/fetcher), video hosts (yt-dlp), or paywall bypass.


Canonical Vocabulary

Term Meaning NOT
extract Single URL → clean text via CLI full crawl harvest
metadata JSON output with with_metadata bare URL probe only
pipe Stdin or local .html file as input download from URL
discover --feed / --sitemap / --crawl / --probe with --list bulk download
batch -i link list → output directory silent mass scrape
local --input-dir reprocess saved HTML live fetch
archived --archived Internet Archive fallback paywall bypass
precision --precision — less noise default when content missing
recall --recall — more text default when noise high
doctor Preflight JSON for binary and version live URL smoke

Dispatch

$ARGUMENTS Mode Action
doctor / preflight Doctor Run scripts/doctor.py --format json
extract <url> / bare https://… Extract Stdout-first via extract_url.py
metadata <url> Metadata extract_url.py with --with-metadata --format json
pipe <file> / stdin HTML Pipe trafilatura on file or stdin
discover feed <url> Discover list_urls.py --mode feed (--list only)
discover sitemap <url> Discover list_urls.py --mode sitemap
discover crawl <url> Discover list_urls.py --mode crawl
discover probe <url> Discover list_urls.py --mode probe
batch <listfile> Batch Approval gate → -i + -o under user dir
local <input-dir> Local Approval gate → --input-dir + -o
archived <url> Archived extract_url.py --archived after normal fetch fails
Natural language: "main text", "clean article", "extract from URL" Auto Map to extract (stdout-first)
(empty) Help Gallery + protocol + references

Auto-Detection Heuristic

  1. URL + "sitemap", "feed", "crawl", "list URLs" → Discover (--list only).
  2. URL + "metadata", "title", "author", "date" → Metadata.
  3. Path to .html or "pipe", "stdin", "local file" → Pipe.
  4. Path to URL list file or "batch" → Batch (approval gate).
  5. Directory of saved HTML → Local (approval gate).
  6. "Archive", "wayback", "link rot" after failed fetch → Archived.
  7. Bare URL or "extract", "clean", "article text" → Extract.
  8. Ambiguous → ask: extract, metadata, discover list, or batch?

Stdout-First Protocol

Run stages in order. Do not skip doctor after CLI errors. Do not batch-write until single-URL needs are met or the user explicitly approves bulk scope.

Stage 1 — Doctor (once per session or after errors)

uv run python scripts/doctor.py --format json

Stop on ok: false or any check with status: fail (missing trafilatura binary).

Stage 2 — Extract (preferred for single URLs)

uv run python scripts/extract_url.py --url 'https://…' --format json

Markdown (default readable):

uv run python scripts/extract_url.py --url 'https://…' --output-format markdown

From probe JSON, report: url, title, date (if metadata), text_length, and format. Load references/output-formats.md when choosing formats.

Stage 3 — Discover (list only by default)

uv run python scripts/list_urls.py --mode sitemap --url 'https://…' --format json

Present url_count and a sample of URLs. Do not chain into batch download without explicit user approval.

Stage 4 — Batch / local (explicit approval required)

Before running:

  1. Confirm URL count or directory scope.
  2. Confirm output directory (default: $HOME/Downloads/trafilatura/output/).
  3. Confirm politeness acknowledgment — see references/politeness-and-ethics.md.
mkdir -p "$HOME/Downloads/trafilatura/output"
trafilatura -i list.txt -o "$HOME/Downloads/trafilatura/output/" --markdown --backup-dir "$HOME/Downloads/trafilatura/html-backup/"

Stage 5 — Escalation (missing or blocked content)

  1. Retry with --recall (CLI) or --recall flag on extract_url.py.
  2. If download blocked: wget -qO- 'URL' | trafilatura or curl -sL 'URL' | trafilatura.
  3. If unavailable: extract_url.py --archived or trafilatura --archived -u 'URL'.
  4. If still empty: note JS-rendered page limitation — no in-tool browser automation. See references/troubleshooting.md.

MCP fallback (no Bash)

When doctor fails because the harness has no shell, use MCPHub trafilatura → fetch_and_extract. Document degraded path. See references/mcp-fallback.md.


Mode Details

Extract

  • Use bundled extract_url.py (wraps trafilatura -u).
  • Read-only regarding repo tree; stdout or JSON envelope only.
  • Default output: markdown for human summary; json when structured metadata is needed.

Metadata

uv run python scripts/extract_url.py --url 'https://…' --output-format json --with-metadata

Pipe

trafilatura --markdown < page.html
cat page.html | trafilatura --json --no-tables

Discover

Modes: feed, sitemap, crawl, probe. Always --list via list_urls.py unless user explicitly requests harvest.

Optional filters: --url-filter, --target-language (requires trafilatura[all]). See references/discovery.md.

Batch

  • Parse list file (one URL per line).
  • Require approval before -i runs.
  • Recommend --backup-dir for HTML archival.
  • Never write into the agents repo.

Local

  • --input-dir for previously downloaded HTML.
  • Mirror structure with --keep-dirs when needed.
  • Approval gate same as batch.

Archived

  • Use when fetch_url equivalent returns nothing.
  • Slow; best for small URL sets.

Doctor

uv run python scripts/doctor.py --format json

Help

Show dispatch table, stdout-first protocol, default paths, and reference index.

Gallery (Empty Arguments)

# Task Example
1 Preflight /trafilatura doctor
2 Extract article /trafilatura extract https://example.org/article
3 Metadata JSON /trafilatura metadata https://example.org/article
4 Discover sitemap /trafilatura discover sitemap https://example.org
5 Pipe local HTML /trafilatura pipe saved-page.html
6 Archived fallback /trafilatura archived https://example.org/missing

Pick a number, a mode from the dispatch table, or paste a URL and say whether you need extract, metadata, or URL discovery.


Critical Rules

  1. Doctor before first extract in a session (or after CLI errors).
  2. Stdout-first for single URLs — use extract_url.py before filesystem batch writes.
  3. Discover list-only by default — present URL count; no auto bulk download.
  4. Explicit approval for batch/local — confirm scope, output dir, politeness.
  5. No paywall bypass coaching — see references/politeness-and-ethics.md.
  6. Not Fetch MCP primary — article main-text extraction belongs here when trafilatura is appropriate.
  7. Not research — multi-source synthesis uses /research.
  8. Not docling — PDFs and table-heavy documents use docling MCP.
  9. Not yt-dlp — video/audio hosts use /yt-dlp.
  10. Report provenance — URL, format, title/date if present, text length in summary.

Troubleshooting

See references/troubleshooting.md for precision/recall, archived fallback, wget/curl pipe, and JS-rendered pages.


References

File Use when
output-formats.md Choosing txt/json/markdown/xml formats
discovery.md Feed, sitemap, crawl, url-filter
troubleshooting.md Missing content, blocked downloads
politeness-and-ethics.md Robots, rate limits, refusals
mcp-fallback.md Shell-less harness / MCPHub path

Scripts

Script Purpose
scripts/doctor.py JSON preflight: trafilatura binary and version
scripts/extract_url.py Single-URL CLI wrapper with JSON envelope
scripts/list_urls.py Discovery --list wrapper
scripts/check.py Validate skill manifest and evals

Examples

# Preflight
uv run python scripts/doctor.py --format json

# Extract (stdout-first)
uv run python scripts/extract_url.py --url 'https://github.blog/2019-03-29-leader-spotlight-erin-spiceland/' --output-format markdown

# Metadata JSON
uv run python scripts/extract_url.py --url 'https://example.org' --output-format json --with-metadata

# Discover sitemap URLs (list only)
uv run python scripts/list_urls.py --mode sitemap --url 'https://www.sitemaps.org/' --format json

# Pipe local HTML
trafilatura --markdown < saved.html

# Batch (after user approval)
trafilatura -i urls.txt -o "$HOME/Downloads/trafilatura/output/" --markdown --backup-dir "$HOME/Downloads/trafilatura/html-backup/"

当前收录版本

1.0.0

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值78/100

待提升项

  • 缺少 When to Use 显式章节 原报告严重程度:轻微

    文档未设置独立的 'When to Use' 章节,虽然 Scope 和 Critical Rules 隐含了使用场景,但显式章节更符合用户快速理解习惯。

    改进建议:在 frontmatter 后或 Gallery 前增加 'When to Use' 小节,简明列出典型用例(如:提取单篇文章正文、获取元数据 JSON、发现站点链接列表)。

亮点

  • 提供网页正文与元数据提取的通用能力,适用于内容抓取、信息结构化等明确场景
  • stdout-first 协议确保单 URL 场景优先输出,避免误触发批量操作
  • 内置 politeness 与 ethics 提醒,符合网络爬虫最佳实践
触发精准92/100

亮点

  • argument-hint 明确列出所有模式与参数格式
  • Auto-Detection Heuristic 提供自然语言到命令的映射逻辑
  • dispatch 表覆盖完整,边界清晰,避免与其他 Skill 重叠
结构规范95/100

待提升项

  • 文档较长 原报告严重程度:轻微

    主文档超过 500 行,虽信息完整但可能影响快速查阅体验。

    改进建议:考虑将部分参考内容(如 Gallery、Examples)移至独立文件并通过链接引用,保持主流程简洁。

亮点

  • Phase 划分清晰(Doctor → Extract → Discover → Batch → Escalation),执行路径明确
  • 每个阶段均有具体命令示例与出口条件说明
  • frontmatter 完整,包含 name、description、argument-hint、license 等必要字段
执行可靠88/100

亮点

  • doctor 预检机制确保 trafilatura 二进制可用后再执行提取
  • archived 回退机制处理链接失效场景
  • 批量操作需显式用户确认,避免误触发大规模抓取
  • 明确声明不支持 paywall bypass、JS 渲染页面等限制,管理用户预期
证据可验 (前四项均值)88/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • example.org
  • github.blog
  • github.com
  • www.sitemaps.org

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。