Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nstevens1040/anglesharpparser

This .NET 6.0 library uses AngleSharp to parse an HTML string into a DOM. It is written such that it can be easily used in PowerShell Core.
https://github.com/nstevens1040/anglesharpparser

csharp document-object-model dom dotnet-6 dotnet-core html net-core net-core-6 net6 parse parser powershell powershell-core

Last synced: 27 days ago
JSON representation

This .NET 6.0 library uses AngleSharp to parse an HTML string into a DOM. It is written such that it can be easily used in PowerShell Core.

Awesome Lists containing this project

README

        

[![Build status](https://ci.appveyor.com/api/projects/status/115e41aqm9s820b5?svg=true)](https://ci.appveyor.com/project/nstevens1040/anglesharpparser)
# AngleSharpParser
## PowerShell Core Quick Start
### Load the DLL into PowerShell Core
```ps1
try { Set-ExecutionPolicy Bypass -Scope Process -Force } catch {}
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
[System.Net.WebClient]::New().DownloadFile(
"https://github.com/nstevens1040/AngleSharpParser/releases/latest/download/AngleSharpParser-latest.nupkg",
"$($ENV:USERPROFILE)\Desktop\AngleSharpParser-latest.nupkg"
)
$null = mkdir "$($ENV:USERPROFILE)\Desktop\AngleSharpParser-latest"
Expand-Archive -Path "$($ENV:USERPROFILE)\Desktop\AngleSharpParser-latest.nupkg" -DestinationPath "$($ENV:USERPROFILE)\Desktop\AngleSharpParser-latest"
Add-Type -Path "$($ENV:USERPROFILE)\Desktop\AngleSharpParser-latest\lib\net6.0\AngleSharpParser.dll"
```
### Do a simple test
```ps1
$html_string = @"




Testing HTML


Heading




subtitle


paragraph


Test succeeded!


"@
$parser = [Angle.Sharp]::New()
$document = $parser.GetDomDocument($html_string)
$document.GetElementById("test").TextContent
```
The output should read
```ps1
Test succeeded!
```