Skip to content
Back to skills

Trafilatura

ASecurity

"Use Trafilatura for web text discovery, downloading, extraction,

  • 247 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 9, 2026
toolsjavascriptpythonjavashellbashapibackend

Works with

  • cli
  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 20 files and shows the line behind each finding

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill trafilatura --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Trafilatura?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Trafilatura
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-trafilatura/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-trafilatura)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: trafilatura
description: "Use Trafilatura for web text discovery, downloading, extraction,
  metadata, CLI batch processing, deduplication, and structured corpus outputs."
disable-model-invocation: true
metadata:
  disco-role: operating
license: Apache 2.0
---

# Trafilatura Repo Skill

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.

## Before you start

1. Install or verify the package:
   ```bash
   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
   ```
2. If optional features are requested, install the relevant extra instead of assuming it is present:
   - `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.
3. Run [scripts/check_trafilatura_environment.py](scripts/check_trafilatura_environment.py) for a no-network import, CLI, extraction, metadata, and deduplication smoke check.
4. Read [references/repo-provenance.md](references/repo-provenance.md) when checking whether this skill matches a current checkout or before refreshing the skill.
5. Read [references/package-overview.md](references/package-overview.md) for the shared capability map, output formats, install extras, and common constraints.
6. Use [references/troubleshooting.md](references/troubleshooting.md) for install/import, CLI PATH, optional-extra, config, network, and routing failures that cross sub-skill boundaries.

## Route by task

| User task or signal | Read |
| --- | --- |
| In-memory Python extraction from HTML strings, bytes, `Response` objects, or LXML trees | [sub-skills/python-extraction/SKILL.md](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](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](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](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](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](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](sub-skills/corpus-quality/SKILL.md) |

## Common decisions

- Use Python APIs when the workflow already has HTML in memory or needs downstream parsing and programmatic error handling.
- Use the CLI when the workflow is a shell pipeline, local HTML directory conversion, URL-list batch, or reproducible command recipe.
- Use discovery/download guidance before extraction when URLs must be found, filtered, throttled, or fetched politely.
- Use corpus-quality guidance when many pages must be validated, deduplicated, fingerprinted, or converted into analysis-friendly structured outputs.
- Treat live network access, large crawls, benchmark corpora, credentials, and optional extras as explicit runtime decisions. The bundled scripts are no-network checks.

## Minimal Python extraction

```python
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")
```

## Minimal CLI extraction

```bash
trafilatura --help
cat page.html | trafilatura --markdown --with-metadata --no-comments
trafilatura --input-dir html-pages --output-dir extracted --json --parallel 2
```

## Scope boundaries

- Trafilatura can help discover and crawl within documented limits, but it is not a full anti-bot bypass, browser automation, authentication, JavaScript rendering, or web-scale crawler system.
- Optional language detection and some speed/download backends need optional extras; absence of those extras should be reported as a capability limit.
- Benchmark/evaluation workflows are intentionally separate from ordinary extraction because they require extra packages and larger data.
- Runtime guidance in this skill is self-contained and should not require reopening the source repository.

Files in this skill

  • SKILL.md5.6 KB
  • references/package-overview.md5.2 KB
  • references/repo-provenance.md3.4 KB
  • references/repo-routing-metadata.json404 B
  • references/troubleshooting.md5.2 KB
  • scripts/check_trafilatura_environment.py5.2 KB
  • sub-skills/cli-batch-processing/SKILL.md3.6 KB
  • sub-skills/cli-batch-processing/references/batch-workflows.md9.2 KB
  • sub-skills/cli-batch-processing/references/cli-reference.md9 KB
  • sub-skills/cli-batch-processing/references/troubleshooting.md9.1 KB
  • sub-skills/cli-batch-processing/scripts/cli_fixture_runner.py6.5 KB
  • sub-skills/corpus-quality/SKILL.md3.2 KB
  • sub-skills/corpus-quality/references/benchmarks-and-evaluation.md8.3 KB
  • sub-skills/corpus-quality/references/data-formats-and-quality.md8.9 KB
  • sub-skills/corpus-quality/references/deduplication.md7.3 KB
  • sub-skills/corpus-quality/references/troubleshooting.md7.3 KB
  • sub-skills/corpus-quality/scripts/corpus_quality_smoke.py4.2 KB
  • sub-skills/discovery-downloads/SKILL.md2.8 KB
  • sub-skills/discovery-downloads/references/api-reference.md13.5 KB
  • sub-skills/discovery-downloads/references/troubleshooting.md13.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…