技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
trafilatura【数据与研究】Use Trafilatura for web text discovery, downloading, extraction, metadata, CLI batch processing, deduplication, and structured corpus outputs.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this skill when a task involves Trafilatura, or when the task is about extracting clean text and metadata from HTML, preparing web-corpus data, discovering article URLs from feeds/sitemaps/crawls, or using a Python/CLI web-scraping tool that outputs TXT, Markdown, JSON, CSV, HTML, XML, or XML-TEI.
Trafilatura is both a Python package and a command-line tool. It can fetch or accept HTML, isolate main text and metadata, preserve selected structure, process batches, deduplicate repeated text, and produce corpus-friendly outputs.
python -m pip install trafilatura
python - <<'PY'
import trafilatura
print(trafilatura.__version__)
print(trafilatura.extract('<html><body><p>Hello from Trafilatura.</p></body></html>'))
PY
trafilatura[all] for language detection, faster encoding/compression/date handling, SOCKS proxy support, and pycurl-based download fallback.trafilatura[eval] only for benchmark/evaluation comparisons; it is not needed for normal extraction.| User task or signal | Read |
|---|---|
In-memory Python extraction from HTML strings, bytes, Response objects, or LXML trees | sub-skills/python-extraction/SKILL.md |
Choose extract(), bare_extraction(), extract_metadata(), html2txt(), baseline(), output formats, metadata, comments, tables, links, images, or Extractor options | sub-skills/python-extraction/SKILL.md |
Use the trafilatura command, stdin, -u/--URL, URL lists, local directories, output directories, backups, --keep-dirs, --parallel, or --config-file | sub-skills/cli-batch-processing/SKILL.md |
| Build shell commands for TXT/Markdown/JSON/HTML/XML/XML-TEI output or CLI metadata/dedup/precision/recall flags | sub-skills/cli-batch-processing/SKILL.md |
Download pages with fetch_url()/fetch_response(), inspect Response, manage polite URL queues, or troubleshoot SSL/proxy/timeouts | sub-skills/discovery-downloads/SKILL.md |
Discover URLs from feeds, sitemaps, focused crawling, --feed, --sitemap, --crawl, --explore, --probe, --archived, --url-filter, or --list | sub-skills/discovery-downloads/SKILL.md |
| Build a corpus, choose JSON/CSV/XML/XML-TEI, validate TEI/XML, deduplicate boilerplate, compute Simhash/fingerprints, or understand evaluation benchmarks | sub-skills/corpus-quality/SKILL.md |
from trafilatura import extract
html = """<html><body><article><h1>Title</h1><p>Main article text with enough content.</p></article></body></html>"""
text = extract(html, output_format="txt", include_comments=False)
if text is None:
# See python-extraction troubleshooting for size thresholds, recall mode, and fallbacks.
raise RuntimeError("Trafilatura found no usable main text")
trafilatura --help
cat page.html | trafilatura --markdown --with-metadata --no-comments
trafilatura --input-dir html-pages --output-dir extracted --json --parallel 2