Public/Get-Spotprent.ps1
function Get-Spotprent { $DutchCulture = New-Object -TypeName System.Globalization.CultureInfo -ArgumentList 'nl-NL' [string[]]$PossibleDateFormats = @('d MMMM yyyy', 'd MMMM') $Elements = Invoke-WebRequest -Uri https://www.trouw.nl/cartoons/spotprent~bdea29f4/ ` | Select-Object -ExpandProperty Content | pup '.artstyle__main--container json{}' --plain | ConvertFrom-Json | Select-Object -ExpandProperty Children $Dates = $Elements | Where-Object tag -In 'h3', 'p' | Select-Object -ExpandProperty text | ForEach-Object { [DateTime]::ParseExact($_, $PossibleDateFormats, $DutchCulture, 'AllowWhiteSpaces') } $Images = $Elements | Where-Object tag -EQ figure | ForEach-Object { $_.Children.Children | Where-Object tag -EQ img | Select-Object -ExpandProperty 'data-original' } (0..($Images.Length - 1)) | ForEach-Object { [PSCustomObject]@{ PSTypeName = 'UncommonSense.Trouw.Article' Url = $Images[$_] Date = $Dates[$_] Title = 'Spotprent' Body = $Images[$_] } } } |