#!/usr/bin/env pwsh
# requirements: PowerHTML (Install-Module PowerHTML)
Import-Module PowerHTML

# reads Wikipedia text about PowerShell and
# loops over all <h2> headers
$url = 'https://en.wikipedia.org/wiki/PowerShell'
$dom = ConvertFrom-Html -URI $url
$content = $dom.SelectSingleNode("//div[@id='bodyContent']")

$headings = $content.SelectNodes(".//div[contains(@class,'mw-heading2')]/h2")
foreach ($h in $headings) {
    Write-Output $h.InnerText
}
