Soenneker.Html.Parser
4.0.1321
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Html.Parser --version 4.0.1321
NuGet\Install-Package Soenneker.Html.Parser -Version 4.0.1321
<PackageReference Include="Soenneker.Html.Parser" Version="4.0.1321" />
<PackageVersion Include="Soenneker.Html.Parser" Version="4.0.1321" />
<PackageReference Include="Soenneker.Html.Parser" />
paket add Soenneker.Html.Parser --version 4.0.1321
#r "nuget: Soenneker.Html.Parser, 4.0.1321"
#:package Soenneker.Html.Parser@4.0.1321
#addin nuget:?package=Soenneker.Html.Parser&version=4.0.1321
#tool nuget:?package=Soenneker.Html.Parser&version=4.0.1321
Soenneker.Html.Parser
Downloads and parses HTML with AngleSharp, with helpers for extracting anchors and image URLs.
Install
dotnet add package Soenneker.Html.Parser
Register
using Soenneker.Html.Parser.Registrars;
services.AddHtmlParserUtilAsSingleton();
Use AddHtmlParserUtilAsScoped() when the parser and its HTTP client should be owned by a dependency-injection scope.
Parse HTML
using AngleSharp.Dom;
using Soenneker.Html.Parser.Abstract;
IDocument document = await parser.Parse(html, cancellationToken);
string? title = document.QuerySelector("title")?.TextContent;
IElement? heading = document.QuerySelector("main h1");
AngleSharp parses with browser-style error recovery, so malformed markup may produce a repaired document rather than an exception.
Download and extract links
List<string> anchors = await parser.GetAllAnchors(
"https://example.com/docs",
cancellationToken);
(List<string> pageAnchors, List<string> images) =
await parser.GetAnchorsAndImageUrls(
"https://example.com/docs",
cancellationToken);
Anchor helpers return unique, non-empty href strings exactly as written in the document; relative links are not resolved. The combined helper downloads and parses the page once.
Extract image URLs from existing HTML
List<string> images = await parser.GetAllUrlsFromImgTagsFromHtml(
html,
"https://example.com/catalog/",
cancellationToken);
This reads img[src], resolves relative values against the base URI, and returns unique HTTP(S) URLs. Data, JavaScript, file, and other schemes are ignored.
GetAllImageUrlsViaRegexFromHtml() is a separate text scan for absolute HTTP(S) image URLs ending in a common image extension. It does not understand HTML, resolve relative paths, inspect srcset, or retain query strings after the extension; prefer the DOM-based helper for normal pages.
The download APIs use HttpClient.GetStringAsync, require a successful response, and buffer the response body as a string. Do not expose arbitrary user-supplied URLs to these methods without applying your application's SSRF controls.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Soenneker.AngleSharp.Parser (>= 4.0.63)
- Soenneker.Extensions.String (>= 4.0.736)
- Soenneker.Html.Client (>= 4.0.1085)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.1333 | 0 | 9/7/2026 |
| 4.0.1332 | 38 | 9/6/2026 |
| 4.0.1331 | 44 | 9/5/2026 |
| 4.0.1330 | 41 | 9/5/2026 |
| 4.0.1329 | 117 | 9/4/2026 |
| 4.0.1328 | 46 | 9/4/2026 |
| 4.0.1327 | 44 | 9/4/2026 |
| 4.0.1324 | 42 | 9/4/2026 |
| 4.0.1323 | 47 | 9/4/2026 |
| 4.0.1322 | 44 | 9/4/2026 |
| 4.0.1321 | 49 | 9/4/2026 |
| 4.0.1313 | 86 | 8/30/2026 |
| 4.0.1312 | 85 | 8/30/2026 |
| 4.0.1311 | 97 | 8/30/2026 |
| 4.0.1310 | 83 | 8/30/2026 |
| 4.0.1308 | 82 | 8/30/2026 |
| 4.0.1307 | 95 | 8/30/2026 |
| 4.0.1305 | 85 | 8/29/2026 |
| 4.0.1304 | 85 | 8/29/2026 |
| 4.0.1303 | 90 | 8/29/2026 |
Fix cross-platform image URL resolution