Private/Get-VolkskrantArticle.ps1
function Get-VolkskrantArticle { param ( [Parameter(Mandatory)] [string]$Uri, [ScriptBlock]$UrlFilter = { $_ -like '*/nieuws-achtergrond/*' -or $_ -like '*/cultuur-media/*' } ) $DutchCulture = New-Object -TypeName System.Globalization.CultureInfo -ArgumentList 'nl-NL' Invoke-WebRequest -Uri $Uri ` | Select-Object -ExpandProperty Links ` | Select-Object -ExpandProperty HRef ` | Where-Object -FilterScript $UrlFilter | Where-Object { $_ -notlike '*copyright-auteursrechten-volkskrant*' } | Where-Object { $_ -notlike '*het-colofon-van-de-volkskrant*' } | ForEach-Object { $Url = $_ $Content = Invoke-WebRequest -Uri $Url | Select-Object -ExpandProperty Content $Document = ConvertTo-HtmlDocument -Text $Content $DateText = ($Document | Select-HtmlNode -CssSelector 'time span:first-child').InnerText $Date = [DateTime]::ParseExact($DateText, 'd MMMM yyyy', $DutchCulture) $Title = (($Document | Select-HtmlNode -CssSelector 'h1' -All).InnerText | ForEach-Object { $_.Trim() } | Where-Object { $_ }) -join ' ' $Paragraphs = $Document | Select-HtmlNode -CssSelector 'section.artstyle__main--container p' -All | Where-Object { $_.GetAttributeValue('class', '') -ne 'artstyle__container__text' } $Body = (($Paragraphs).InnerText | ForEach-Object { $_.Trim() } | Where-Object { $_ }) -join ' ' [PSCustomObject][Ordered]@{ PSTypeName = 'UncommonSense.Volkskrant.Article' Url = $Url Date = $Date Title = $Title Body = $Body } } } |