Defuddle for .NET
Keep the article.
Drop the clutter.
Defuddle finds the main content of a web page, removes sidebars, headers, footers, and other non-essential elements, and returns clean HTML or Markdown with the page's metadata.
Unofficial community port of defuddle by Steph Ango (@kepano). Not an official defuddle product.
dotnet add package DefuddleIt targets net10.0 and netstandard2.0. Defuddle on NuGet.
using Defuddle;
var result = DefuddleParser.ParseHtml(
html,
new DefuddleOptions
{
Url = "https://example.com/blog/tide-pools",
Markdown = true,
});
Console.WriteLine(result.Content);Package
Defuddle
A library and a CLI tool
Targets
net10.0
and netstandard2.0
Upstream
0.19.13
Ported from defuddle
License
MIT
Same as upstream
Why Defuddle
The defuddle extraction pipeline, in the C# you already write.
Main content
OptionsDefuddleParserpicks the element that holds the content and removes the clutter around it. SetContentSelectorwhen you already know where it is.Markdown output
Set
MarkdownMarkdownto get Markdown inContent, orSeparateMarkdownto keep the HTML and fillContentMarkdown.Metadata
Title, author, description, publication date, site, images, schema.org data, and meta tags come back on the same response.
ResponseSite extractors
Pages from sites such as GitHub, Reddit, Hacker News, YouTube, Wikipedia, and X have their own extractors, picked by URL.
Extractors
Get started
From a page of HTML to Markdown, in three steps.
Install the package, parse a page, then read the content and metadata. Each step links to the page that has the rest.
Read the quickstartInstall the package
Add
Defuddleto a project that targetsnet10.0ornetstandard2.0.
Quickstartdotnet add package DefuddleParse a page
Pass HTML to
ParseHtml, or an AngleSharp document toDefuddleParser. Give the page URL so links resolve and site extractors can run.
Parse HTMLvar result = DefuddleParser.ParseHtml(html);Or use the terminal
The
Defuddle.Clitool parses a file, a URL, or standard input.
CLIdotnet tool install -g Defuddle.Cli defuddle parse page.html --markdown