Public/Get-DeMeerseHoofddorp.ps1
function Get-DeMeerseHoofddorp { param ( [ValidateSet('cabaret-en-kleinkunst')] # FIXME: Add the rest later! [string]$Genre, [ValidateRange(1, [int]::MaxValue)] [int]$Page = 1 ) $DutchCulture = [cultureinfo]::GetCultureInfo('nl-NL') $Uri = "https://www.demeerse.nl/wp/wp-admin/admin-ajax.php?action=agenda_lazy&type=default&paged=$Page" if ($Genre) { $Uri = ($Uri, "genre%5B%5D=$Genre") -join '&' } Invoke-RestMethod -Uri $Uri | Select-Object -ExpandProperty Items | ConvertTo-HtmlDocument | Select-HtmlNode -CssSelector li -All | Select-Object -ExpandProperty InnerHtml | ForEach-Object { $DateText = ($_ | pup '.date text{}' --plain) -replace '^.{3}', '' -replace ' uur$', '' -replace ' - ', ' ' $DateText = $DateText -replace '([a-z]{3})', '$1.' $Date = [DateTime]::ParseExact($DateText.Trim(), 'd MMM yyyy HH:mm', $DutchCulture, 'AllowWhiteSpaces') [PSCustomObject]@{ PSTypeName = 'UncommonSense.Theater.Event' Genre = $_ | pup '.label text{}' --plain DateText = $DateText Date = $Date Artist = $_ | pup 'h3 text{}' --plain Title = $_ | pup 'small text{}' --plain | Select-Object -First 1 Image = $_ | pup 'img attr{data-src}' --plain Link = $_ | pup 'a attr{href}' --plain Tags = $_ | pup '.tag text{}' --plain } } } |