Public/Get-AHStore.ps1
# .SYNOPSIS # Retrieves information about Albert Heijn stores function Get-AHStore { [CmdletBinding()] param ( [Parameter(Mandatory, ValueFromPipeLine, Position = 0)] [int[]]$ID ) process { $ID | ForEach-Object { $Url = "https://ah.nl/winkel/$_" $Document = ConvertTo-HtmlDocument -Uri $Url $OpeningHours = $Document | Select-HtmlNode -CssSelector '.store-opening-hours_listItem__SaduL p' -All | Select-Object -ExpandProperty InnerText | Select-Object -Skip 2 # Headers | ForEach-Object { $_ | Add-Member -NotePropertyName Day -NotePropertyValue ([System.DayOfWeek]((([Math]::Floor($Index++ / 3)) + 1) % 7)) -PassThru } | Group-Object -Property Day | ForEach-Object { $DayThisWeek = Get-DateFromWeekDay This $_.Name $DayNextWeek = Get-DateFromWeekDay Next $_.Name $TimesThisWeek = $_.Group | Select-Object -Skip 1 -First 1 $TimesNextWeek = $_.Group | Select-Object -Skip 2 -First 1 Get-OpeningHours -Date $DayThisWeek -Time $TimesThisWeek Get-OpeningHours -Date $DayNextWeek -Time $TimesNextWeek } $AddressItems = $Document | Select-HtmlNode -CssSelector '.store-address_addressItem__tHKZK' -All [pscustomobject]@{ PSTypeName = 'UncommonSense.AH.Store' ID = $_ Url = $Url Name = ($Document | Select-HtmlNode -CssSelector '.store-details_headingText__ynhSs').InnerText Address = ($AddressItems[0] | Select-HtmlNode -CssSelector 'p' -All | Select-Object -ExpandProperty InnerText | ForEach-Object { $_.Trim() }) -join ', ' PhoneNo = ($AddressItems[2] | Select-HtmlNode -CssSelector 'p' -All | Select-Object -ExpandProperty InnerText) -join ', ' OpeningHours = $OpeningHours | Sort-Object -Property From } } } } |