Public/Get-JoostPrinsen.ps1
function Get-JoostPrinsen { Invoke-WebRequest -Uri 'https://www.haarlemsdagblad.nl/zoeken?keyword=joost+prinsen' | Select-Object -ExpandProperty Links | Select-Object -ExpandProperty Href | Where-Object { $_ -like '/cnt/dmf*' } | ForEach-Object { "https://haarlemsdagblad.nl$($_)" } | ForEach-Object { $CurrentUrl = $_ $Content = Invoke-WebRequest -Uri $CurrentUrl | Select-Object -ExpandProperty Content $ArticleContent = ConvertTo-HtmlDocument -Text $Content | Select-HtmlNode -CssSelector 'script[data-fragment-type=ArticleContent]' | Select-Object -ExpandProperty InnerText | ForEach-Object { $_ -replace '^window\["__PRELOADED_STATE_GRAPH__[^"]*"\] = ', '' } | ConvertFrom-Json $FirstProperty = $ArticleContent.PSObject.Properties | Select-Object -First 1 -ExpandProperty Name $ArticleContent | Select-Object -ExpandProperty $FirstProperty | Select-Object -ExpandProperty data | Select-Object -ExpandProperty article | ForEach-Object { $Intro = $_.Intro | Select-Object -ExpandProperty p | Join-String -Separator "`n" $Body = $_.Body | Select-Object -ExpandProperty p | Join-String -Separator "`n" [PSCustomObject]@{ PSTypeName = 'UncommonSense.HaarlemsDagblad.Article' Url = $CurrentUrl Date = $_.PublishedAt Title = $_.Title -replace '\s\|\scolumn$', '' Body = @($Intro, $Body) -join "`n`n" } } } } |