Public/Get-FilmhuisVeenendaal.ps1
function Get-FilmhuisVeenendaal { [CmdletBinding()] param() $DutchCulture = [CultureInfo]::GetCultureInfo('nl-NL') Invoke-WebRequest -Uri https://www.filmhuisveenendaal.nl/ ` | Select-Object -ExpandProperty Links | Select-Object -ExpandProperty Href | Where-Object { $_ -match 'https://www.filmhuisveenendaal.nl/.+' } | ForEach-Object { $_ -replace '/$', '' } | Where-Object { $_ -notlike '*over-ons*' } | Where-Object { $_ -notlike '*/vereniging*' } | Where-Object { $_ -notlike '*/leden*' } | Where-Object { $_ -notlike '*/nieuwsbrief*' } | Where-Object { $_ -notlike '*/vrijwilliger-worden*' } | Where-Object { $_ -notlike '*/bezoekersinformatie*' } | ForEach-Object { $_.ToLowerInvariant() } | Select-Object -Unique | ForEach-Object { $Url = $_ $Document = ConvertTo-HtmlDocument -Uri $Url $Texts = $Document | Select-HtmlNode -CssSelector '.et_pb_row_2 .et_pb_text_inner' -All $Title = $Texts | Select-Object -First 1 | Get-HtmlNodeText $Paragraphs = $Texts | Select-Object -Skip 1 -First 1 | Select-HtmlNode -CssSelector 'p' -All | Where-Object InnerText -NotLike 'Genre*' | Get-HtmlNodeText $Paragraphs = if ($Texts | Select-Object -Skip 1 -First 1 | Get-HtmlNodeText -DirectInnerTextOnly) { $Texts | Select-Object -Skip 1 -First 1 | Get-HtmlNodeText -DirectInnerTextOnly $Paragraphs } else { $Paragraphs } $Body = $Paragraphs.Trim() -join ' ' $Details = (($Texts | Select-Object -Skip 1 -First 1 | Select-HtmlNode -CssSelector 'p' -All | Where-Object InnerText -Like 'Genre*').InnerHtml -split '<br>').trim() $DateText = $Texts | Select-Object -Skip 4 | ForEach-Object { $_ | Select-HtmlNode -CssSelector 'h3' -All | Get-HtmlNodeText } ($DateText -split 'uur') | Where-Object { $_.Trim() } | ForEach-Object { $Current = $_.Trim().ToLowerInvariant() -replace ',\s+', ',' -replace '^[\D\s]*', '' $Date = [DateTime]::ParseExact($Current, 'd MMMM,HH.mm', $DutchCulture) if ($Date -lt (Get-Date)) { $Date = $Date.AddYears(1) } [PSCustomObject]@{ PSTypeName = 'UncommonSense.Cinema.Film' Url = $Url Date = $Date Title = $Title Body = $Body Genre = $Details | Where-Object { $_ -match '^Genre: (.*)$' } | ForEach-Object { $Matches[1] } Director = $Details | Where-Object { $_ -match '^Regisseur: (.*)$' } | ForEach-Object { $Matches[1] } LeadingRoles = $Details | Where-Object { $_ -match '^Hoofdrollen: (.*)$' } | ForEach-Object { $Matches[1] } RunningTime = $Details | Where-Object { $_ -match '^Speelduur: (.*)$' } | ForEach-Object { $Matches[1] } } } } } |