Public/Get-Sigmund.ps1
<# .SYNOPSIS Retrieves recent Sigmund cartoons #> function Get-Sigmund { $DutchCulture = New-Object -TypeName System.Globalization.CultureInfo -ArgumentList 'nl-NL' [string[]]$Formats = @('d MMMM yyyy', 'd MMMM') $Content = Invoke-WebRequest -Uri 'https://www.volkskrant.nl/nieuws-achtergrond/sigmund~b52ef491' ` | Select-Object -ExpandProperty Content $Dates = $Content | pup '.artstyle__main--container h3 text{}' --plain | ForEach-Object { $_.Trim() } | Where-Object { $_ } | ForEach-Object { [DateTime]::ParseExact($_, $Formats, $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 = 'Sigmund' Body = $Images[$_] } } } |