Public/Get-Picl.ps1
function Get-Picl { [CmdletBinding()] param() $DutchCulture = Get-Culture 'nl-NL' Invoke-WebRequest -Uri 'https://picl.nl/films/' | Select-Object -ExpandProperty Links | Select-Object -ExpandProperty Href | Where-Object { $_ -match '^https://picl.nl/films/.+$' } | ForEach-Object { $Url = $_ $Document = ConvertTo-HtmlDocument -Uri $Url $Title = $Document | Select-HtmlNode -CssSelector 'h1' | Get-HtmlNodeText $ImageUrl = 'https://picl.nl' + ($Document | Select-HtmlNode -CssSelector '.hero__background img').Attributes['src'].Value $Synopsis = $Document | Select-HtmlNode -CssSelector '.movie-hero__intro' | Get-HtmlNodeText $Description = $Document | Select-HtmlNode -CssSelector '.movie__description > p' -All | Get-HtmlNodeText -SkipRemoveLineBreaks $Availability = ($Document | Select-HtmlNode -CssSelector '.movie-hero__payoff' | Get-HtmlNodeText) if (-not $Availability) { $Availability = $Document | Select-HtmlNode -CssSelector '.movie-teaser__availability' | Get-HtmlNodeText } if (-not $Availability.EndsWith('.')) { $Availability = "$Availability." } $Meta = $Document | Select-HtmlNode -CssSelector '.movie-meta p' -All $MetaLabels = $Document | Select-HtmlNode -CssSelector '.movie-meta h3' -All | ForEach-Object { $_ | Get-HtmlNodeText } | Select-Object -Skip 1 $AvailableUntilIndex = $MetaLabels.IndexOf('Te zien tot') $GenreIndex = $MetaLabels.IndexOf('Genre') $CountryIndex = $MetaLabels.IndexOf('Land') $LanguageIndex = $MetaLabels.IndexOf('Taal') $AvailableUntilText = '' $AvailableUntil = $null if ($AvailableUntilIndex -ne -1) { $AvailableUntilText = $Meta[$AvailableUntilIndex] | Get-HtmlNodeText $AvailableUntil = [DateTime]::ParseExact($AvailableUntilText, 'd MMMM yyyy', $DutchCulture) $Availability = "Te zien tot $AvailableUntilText. " + $Availability } $Genre = $Meta[$GenreIndex] | Get-HtmlNodeText $Country = $Meta[$CountryIndex] | Get-HtmlNodeText $Language = $Meta[$LanguageIndex] | Get-HtmlNodeText [PSCustomObject]@{ PSTypeName = 'UncommonSense.Cinema.PiclFilm' Url = $Url Title = $Title ImageUrl = $ImageUrl Synopsis = $Synopsis Description = $Description Genre = $Genre Country = $Country Language = $Language Availability = $Availability AvailableUntil = $AvailableUntil } } } |