Created
December 13, 2021 15:17
-
-
Save stelf/2cd411b7e2ddf10c6876f17c79d92aea to your computer and use it in GitHub Desktop.
workaround the querySelectorAll bug that shows when calling it from COM+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$comDoc = New-Object -Com 'HTMLFile' | |
# load the wiki content | |
$res = Invoke-WebRequest $webLocation | |
# create a webview | |
$comDoc.Write( [System.Text.Encoding]::Unicode.GetBytes($res.Content) ) | |
# query DOM | |
$elems = $comDoc.querySelector('table.prettytable') | |
# unfortunately querySelectorAll fails for various reasons | |
# so we have to enumerate the items manually | |
$codes = $elems.childNodes().item(0).childNodes() ` | |
| ForEach-Object { | |
$_.ChildNodes().item(5).innerText -match '(\w+)(?:\sor\s(\w+))*'; | |
($matches[1], $matches[2]) } ` | |
| Sort-Object | Get-unique | |
$codes -notmatch 'File' -join ' ' | Write-Host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment