Trafilatura exposes two configuration layers. The first isDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/adbar/trafilatura/llms.txt
Use this file to discover all available pages before exploring further.
settings.cfg, a standard INI-style file that controls runtime tunables such as download timeouts, size thresholds, and deduplication limits — these are the values most users will want to adjust. The second is settings.py, a Python module that governs package-wide constants (HTML element lists, parallel-processing limits, LRU cache sizes) and requires a local reinstall when changed.
settings.cfg
The default configuration file ships inside the package attrafilatura/settings.cfg. You can inspect it directly on GitHub. Providing a custom file — either on the command line or in Python — overrides only the keys you specify; all other values fall back to the defaults.
Download
Time in seconds before an HTTP request is dropped. Increase this on slow networks or when scraping heavy pages.
Maximum acceptable input size in bytes (≈ 20 MB). Documents larger than this value are skipped.
Minimum acceptable input size in bytes. Responses smaller than this value are treated as empty.
Pause in seconds between consecutive requests when crawling. Higher values reduce the risk of being rate-limited or flagged as a bot.
One user-agent string per line. Leave empty to use the library default. Example:
Cookie string to send with every HTTP request. Useful for sites that require session authentication.
Maximum number of URL redirections to follow. Set to
0 to disable redirect following entirely.Extraction
Minimum character count for the main-text extraction to be considered successful before falling back to alternative extractors. Lowering this value enables more opportunistic extraction on short pages.
Same threshold applied to comment extraction.
Absolute minimum character count for the final main-text output. Documents below this threshold are discarded entirely.
Same threshold applied to the final comment output.
Discard documents whose parsed HTML tree contains more elements than this number. Leave empty (the default) to impose no limit. Useful for skipping abnormally large or malformed pages.
Seconds before a single extraction is aborted. Only active in CLI/file-processing mode. Set to
0 to disable. If you see errors related to the signal module, set this to 0 or consider using defusedxml.Deduplication
Deduplication is not active by default. Enable it per-call with
deduplicate=True or options.dedup = True. See the Deduplication page for full details.Minimum character length of a text segment before it is evaluated for duplicates. Shorter segments are always kept.
Maximum number of times a segment may appear before it is flagged as a duplicate and removed.
Metadata
Controls
htmldate’s opportunistic date search across the full page content. Set to off for higher precision at the cost of lower recall. See Metadata for full details.Navigation
Whether to follow URLs pointing to other domains when processing feeds and sitemaps in CLI mode. Keeping this
off limits crawling to the target domain.Using a custom configuration file
On the command line
Pass the path to your custom file with the--config-file option. The custom file is merged over the defaults, so you only need to include the keys you want to override:
In Python
- use_config()
- Override a single value
Load a complete settings file and pass it to any extraction function via the
config= parameter:The Extractor class
Since version 1.9, all extraction parameters — including those that used to require a config file — can be bundled into anExtractor object and passed directly to extract() or bare_extraction(). This is the preferred approach for programmatic use because it is explicit, type-safe, and avoids repeating keyword arguments across many calls.
Import and instantiation
Key attributes
Output format. Supported values:
"csv", "html", "json", "markdown", "txt", "xml", "xmltei". Use "python" with bare_extraction() to receive a Document object.Use faster heuristics and skip the backup extractor. Trades recall for speed.
Extraction strategy. Set via
precision=True (fewer but correct segments) or recall=True (more text, less strict). Passing both raises a warning and recall takes precedence.Whether to extract comment sections alongside the main text.
Preserve formatting elements such as bold, italic, and headings. Defaults to
True when output_format is "markdown". Ignored for JSON output.Keep hyperlinks and their targets in the output (experimental).
Include image references in the output (experimental).
Extract content from HTML
<table> elements.Activate segment-level deduplication using the LRU cache.
Target language as an ISO 639-1 code (e.g.
"en", "de"). Documents detected as a different language are discarded.Extract and include metadata fields (title, author, date, etc.) in the output.
Discard documents that do not have all three essential metadata fields:
date, title, and url.Validate the XML-TEI output against the TEI standard. Only meaningful when
output_format="xmltei".Pass custom parameters to
htmldate for date extraction. Overrides the EXTENSIVE_DATE_SEARCH config value.A set of author names to exclude from the output.
A set of URLs to filter out during extraction.
Reusing options across many pages
Advanced: editing settings.py
For deeper customization — such as changing the list of HTML elements that are cleaned or kept, adjusting the LRU cache size (LRU_SIZE), configuring parallel processing (PARALLEL_CORES), or tuning file-output behavior — you can edit settings.py directly.
Locate or clone the package
Find the locally installed copy (e.g. inside your virtualenv’s
site-packages) or clone the repository:Edit settings.py
Open
trafilatura/settings.py and modify the constants you need — for example, increase LRU_SIZE for larger deduplication caches or adjust MANUALLY_CLEANED to preserve specific HTML elements.