Guides

Extract a Web Article for AI with Trafilatura

Extract article text from saved HTML, check for missing evidence and navigation clutter, and retain the original source for verification.

Key takeaway

Clean one saved article HTML file and check specific required text and boilerplate markers.

On this page
  1. Run the local extraction
  2. Check a page before relying on its export
  3. Keep the evidence attached

Before giving an article to an AI assistant, make sure the copied text actually includes the paragraph you want it to reason about. Saved HTML can include menus, newsletter boxes and comments beside the article. Trafilatura offers extraction modes that trade off unwanted text against missing article content. Trafilatura extraction overview

Run the local extraction

Download the HTML fixture saved as text and the extraction script. The fixture is a fictional help article with distinctive menu and footer markers. The script reads the local file and writes a separate text export.

python -m pip install trafilatura==2.3.1
python extract-html-article.py html-extraction-fixture.txt article.txt

On November 11, 2026, the default precision run saved 116 words. It kept the heading and all three article paragraphs, including error code ERR-812. Both BOILERPLATE-NAV and BOILERPLATE-FOOTER were absent. Observed text output

Check a page before relying on its export

Choose two or three details from the original page that matter for your task. For this fixture, those details are the error code, the need to start a fresh job, and the condition that the download link appears after completion. Find each in the extracted text. A short, clean export can still drop a condition that changes the answer.

If an important paragraph is missing, save a separate export with broader extraction:

python extract-html-article.py html-extraction-fixture.txt article-recall.txt --recall

Compare the two files around the missing paragraph. Broader extraction may pull in unrelated material. If the saved HTML itself lacks the article, check how it was saved. A browser can show text that was loaded after the initial HTML response. The local script works with the bytes you give it.

Keep the evidence attached

Save the original URL, capture date and the unmodified HTML alongside the cleaned text. When asking an assistant to summarize it, request the supporting sentence for each important claim. For a table, check that its column headers and values still line up. If layout is central to the claim, cite or inspect the original view as well.

This fixture checks one article-shaped page. Complex tables, discussion threads and interactive documentation need their own checks. For reading and comparing original-language text side by side, see the bilingual reading workflow.

Sources & references

Written by Modelrovia Editorial. Our standards distinguish official claims from observed results.

How we research and test →

Tools in this article