Debugging
Debug mode
Section titled “Debug mode”Set Debug to get a Debug object on the response.
var result = DefuddleParser.ParseHtml(html, new DefuddleOptions { Debug = true });
if (result.Debug is { } debug){ Console.WriteLine(debug.ContentSelector); foreach (var removal in debug.Removals) { Console.WriteLine($"{removal.Step}: {removal.Reason} {removal.Selector}"); }}Debug mode also keeps class, id, and data-* attributes that are normally stripped, and skips div flattening, so the output keeps the structure of the page.
DebugInfo has these properties:
| Property | Description |
|---|---|
ContentSelector |
CSS selector path of the chosen main content element. |
Removals |
Elements removed during processing. |
Errors |
Errors caught and recovered from, such as a ContentSelector that cannot be parsed. |
When every attempt fails, the response contains the whole page body and ContentSelector is empty. A page nested more than 512 levels deep is one such case: the content is then the plain text of the body.
Each DebugRemoval has these properties:
| Property | Description |
|---|---|
Step |
Pipeline step that removed the element: removeHiddenElements, removeEyebrowLabel, removeBySelector, scoreAndRemove (the step RemoveLowScoring controls), or removeByContentPattern. |
Selector |
Selector or pattern that matched, for selector-based removal. |
Reason |
Why the element was removed, such as display:none. |
Text |
The start of the removed element’s text. |
Pipeline toggles
Section titled “Pipeline toggles”Turn steps off one at a time to find the one that removes your content.
var unfiltered = DefuddleParser.ParseHtml( html, new DefuddleOptions { RemoveLowScoring = false, // keep blocks that scoring would remove RemoveHiddenElements = false, // keep hidden elements, such as CSS sidenotes RemoveSmallImages = false, });Content selector
Section titled “Content selector”Use ContentSelector to bypass auto-detection. If it matches nothing, Defuddle falls back to auto-detection.
var selected = DefuddleParser.ParseHtml(html, new DefuddleOptions { ContentSelector = "article" });MIT · Copyright 2025 Steph Ango (@kepano) · unofficial community port of defuddle