Public/Get-FilmtheaterHilversum.ps1
function Get-FilmtheaterHilversum { $DutchCulture = Get-Culture 'nl-NL' $Today = Get-Date -Hour 0 -Minute 0 -Second 0 -Millisecond 0 $Tomorrow = $Today.AddDays(1) Invoke-WebRequest -Uri https://www.filmtheaterhilversum.nl/films/ ` | Select-Object -ExpandProperty Links ` | Where-Object Href -Like 'https://filmtheaterhilversum.nl/film/*' | Select-Object -ExpandProperty HRef ` | ForEach-Object { Write-Verbose "Processing movie url $($_)" $Url = $_ $Document = ConvertTo-HtmlDocument -Uri $Url $Title = $Document | Select-HtmlNode -CssSelector 'h1' | Get-HtmlNodeText $Body = $Document | Select-HtmlNode -CssSelector '.content p strong' | Get-HtmlNodeText $Document | Select-HtmlNode -CssSelector '.movie-time' -All | ForEach-Object { $CurrentMovieTime = $_ $ScreenDay = $CurrentMovieTime | Select-HtmlNode -CssSelector '.movie-screenday' | Get-HtmlNodeText Write-Verbose "- Screen day '$($ScreenDay)'" $ScreenDay = switch -regex ($ScreenDay) { 'Vandaag' { $Today; break; } 'Morgen' { $Tomorrow; break; } '^\w{2}\s\d{1,2}\s\w{3}$' { [DateTime]::ParseExact($ScreenDay.SubString(3), 'd MMM', $DutchCulture); break; } } if ($ScreenDay -lt $Today) # assume next year if day/month before today (end of December/start of January) { $ScreenDay = $ScreenDay.AddYears(1) } Write-Verbose "- Corrected screen day '$($ScreenDay.ToShortDateString())'" $CurrentMovieTime | Select-HtmlNode -CssSelector '.movie-timeblock' -All | ForEach-Object { $_ | Get-HtmlNodeText } | ForEach-Object { Write-Verbose "- Time '$($_)'"; $_ } | ForEach-Object { [TimeSpan]::ParseExact("$($_):00", 'g', $DutchCulture) } | ForEach-Object { $ScreenDay.Add($_) } } | ForEach-Object { [PSCustomObject]@{ PSTypeName = 'UncommonSense.Cinema.Film' Url = $Url Date = $_ Title = $Title Body = $Body } } } } |