---
source_url: "https://trafilatura.readthedocs.io/en/latest/quickstart.html"
title: Quickstart — Trafilatura 2.2.0 documentation
mirrored_at: 2026-08-15T03:34:30.416Z
host: trafilatura.readthedocs.io
cited_in_42a: true
mirror_canonical: "https://index.42a.ai/trafilatura.readthedocs.io/en/latest/quickstart.html"
---

> **Original source:** https://trafilatura.readthedocs.io/en/latest/quickstart.html

Trafilatura is a tool that simplifies the process of turning raw HTML into structured, meaningful data. This quickstart guide will walk you through the main functions of the software package using Python or the command-line.

To get started, install Trafilatura using a Python package manager: `pip install trafilatura`. For more details, see the [installation documentation](https://trafilatura.readthedocs.io/en/latest/installation.html). You can then import it into your Python script or code.

## With Python[#](#with-python "Link to this heading")

### Customizing output[#](#customizing-output "Link to this heading")

To tailor the output to your specific requirements, Trafilatura allows you to convert the extracted data into various formats. Here are a couple of examples:

\# change the output format to XML (allowing for preservation of document structure)
\>>> result \= extract(downloaded, output\_format\="xml")

\# discard potential comments, extract metadata and change the output to JSON
\>>> extract(downloaded, output\_format\="json", with\_metadata\=True, include\_comments\=False)

\# set the output to Markdown and extract metadata
\>>> extract(downloaded, output\_format\="markdown", with\_metadata\=True)

### Fast mode[#](#fast-mode "Link to this heading")

You can bypass the use of fallback algorithms in fast mode. This can improve performance, but may affect the accuracy of the extraction:

\# faster mode without backup extraction
\>>> result \= extract(downloaded, fast\=True)

For a full list of options see [Python usage](https://trafilatura.readthedocs.io/en/latest/usage-python.html).

### Extracting all text content[#](#extracting-all-text-content "Link to this heading")

While the previous examples focused on extracting the main text from a webpage, Trafilatura also offers a function to extract all text content in a `html2txt` manner:

\>>> from trafilatura import html2txt
\>>> html2txt(downloaded)

### Metadata[#](#metadata "Link to this heading")

The tool can also extract specific information from a web page, such as the title, author, or publication date. You can use the `extract_metadata` function to do this:

\>>> from trafilatura import fetch\_url, extract\_metadata
\>>> downloaded \= fetch\_url('https://github.blog/2019-03-29-leader-spotlight-erin-spiceland/')
\>>> extract\_metadata(downloaded)

## On the command-line[#](#on-the-command-line "Link to this heading")

You can use URLs directly with the `-u` or `--URL` option:

\# outputs main content and comments as plain text
$ trafilatura \-u "https://github.blog/2019-03-29-leader-spotlight-erin-spiceland/"

For a detailed overview of available options, you can display the help message by running `trafilatura -h`.

Additionally, you can pipe the HTML document (including the response body) to Trafilatura for extraction:

$ cat myfile.html | trafilatura \# use the contents of an already existing file
$ < myfile.html trafilatura \# same here

Extraction options are also available on the command-line and they can be combined:

$ < myfile.html trafilatura \--json \--no-tables

## Further steps[#](#further-steps "Link to this heading")

For more information please refer to [usage documentation](https://trafilatura.readthedocs.io/en/latest/usage.html) and [tutorials](https://trafilatura.readthedocs.io/en/latest/tutorials.html).