Private/Get-NrcArticle.ps1
function Get-NrcArticle { param ( [Parameter(Mandatory)] [string]$Uri ) Invoke-WebRequest -Uri $Uri ` | Select-Object -ExpandProperty Links ` | Select-Object -ExpandProperty HRef ` | Where-Object { $_ -like '/nieuws/*' } | ForEach-Object { $Url = "https://nrc.nl$($_)" $DateElements = ($Url -split '/')[4..6] $Document = ConvertTo-HtmlDocument -Uri $Url [PSCustomObject][Ordered]@{ PSTypeName = 'UncommonSense.Nrc.Article' Url = $Url Date = Get-Date -Year $DateElements[0] -Month $DateElements[1] -Day $DateElements[2] Title = ($Document | Select-HtmlNode -CssSelector 'h1').InnerText Body = ($Document | Select-HtmlNode -CssSelector 'div.vorm__article-content p' -All).InnerText -join ' ' -replace 'Lezers zijn de.*$', '' -replace '\s{2,}', ' ' Image = ($Document | Select-HtmlNode -CssSelector 'img') | ForEach-Object { $_.GetAttributeValue('src', '') } } } } |