Public/Get-BasVanDerSchot.ps1
<# .SYNOPSIS Retrieves recent cartoons by Bas van der Schot #> function Get-BasVanDerSchot { $DutchCulture = New-Object -TypeName System.Globalization.CultureInfo -ArgumentList 'nl-NL' $PossibleFormats = [string[]]@('d MMMM yyyy', 'd MMMM') $Content = Invoke-WebRequest -Uri 'https://www.volkskrant.nl/nieuws-achtergrond/bas-van-der-schot~b19fa213' ` | Select-Object -ExpandProperty Content $Dates = $Content | pup '.artstyle__main--container h3 text{}' --plain | ForEach-Object { $_.Trim() } | Where-Object { $_ } | ForEach-Object { [DateTime]::ParseExact($_, $PossibleFormats, $DutchCulture, 'None') } $Images = $Content | pup '.artstyle__main--container img attr{src}' $NoOfItems = ($Dates.Count), ($Images.Count) | Measure-Object -Minimum | Select-Object -ExpandProperty Minimum 0..($NoOfItems - 1) | ForEach-Object { [PSCustomObject][Ordered]@{ PSTypeName = 'UncommonSense.Volkskrant.Article' Url = $Images[$_] Date = $Dates[$_] Title = 'Bas van der Schot' Body = $Images[$_] } } } |