Public/Get-HeinDeKort.ps1
function Get-HeinDeKort { $DutchCulture = New-Object -TypeName System.Globalization.CultureInfo -ArgumentList 'nl-NL' Invoke-WebRequest -Uri 'https://www.parool.nl/nederland/bekijk-hier-alle-cartoons-van-hein-de-kort~b144acc5/' ` | Select-Object -ExpandProperty Content ` | pup 'figure img json{}' --plain ` | ConvertFrom-Json | ForEach-Object { $DateText = $_.'data-title' $DateText = $DateText -replace '\.$', '' # trailing full stops $DateText = $DateText -replace '^hein\s+', '' # leading "hein" $DateText = $DateText -replace 'correctie$', '' # trailing "correctie" $DateText = $DateText -replace '^\s+', '' # leading whitespace $DateText = $DateText -replace '\s+$', '' # trailing whitespace $DateText = $DateText.ToLowerInvariant() $Date = Get-Date if ([DateTime]::TryParseExact($DateText, 'd MMMM yyyy', $DutchCulture, [System.Globalization.DateTimeStyles]::None, [ref]$Date)) { [PSCustomObject][Ordered]@{ PSTypeName = 'UncommonSense.Parool.Article' Url = $_.'data-original' Date = $Date Title = 'Hein de Kort' Body = $_.'data-original' } } } } |