Private/Get-TrouwCartoon.ps1
function Get-TrouwCartoon { param ( [Parameter(Mandatory)] [string]$Uri, [Parameter(Mandatory)] [string]$Title ) $DutchCulture = New-Object -TypeName System.Globalization.CultureInfo -ArgumentList 'nl-NL' $Response = Invoke-WebRequest -Uri $Uri $Images = $Response | Select-Object -ExpandProperty Images | Where-Object { $_.src -Like 'https://image.trouw.nl/*/afbeelding' -or $_.src -match '.*/\d+-\w+-\d{4}$' } | Select-Object -ExpandProperty src $Dates = $Response | Select-Object -ExpandProperty Content | Select-String -Pattern '<h2 class="v2cotm0 _1uudmgm0">(.*?)</h2>' -All | Select-Object -ExpandProperty Matches | ForEach-Object { $_.Groups[1] } | Select-Object -ExpandProperty Value | ForEach-Object { [DateTime]::ParseExact($_, 'd MMMM yyyy', $DutchCulture) } $ImagesEnumerator = $Images.GetEnumerator() $DatesEnumerator = $Dates.GetEnumerator() while ($ImagesEnumerator.MoveNext() -and $DatesEnumerator.MoveNext()) { [PSCustomObject][Ordered]@{ PSTypeName = 'UncommonSense.Trouw.Article' Url = $ImagesEnumerator.Current Date = $DatesEnumerator.Current Title = $Title Body = $ImagesEnumerator.Current } } } |