Last active
April 4, 2025 07:37
-
-
Save Arefu/74df931c8b6848d6bcdb88fa9a283377 to your computer and use it in GitHub Desktop.
Pak 'n Save API Hijinx - Found using Firefox's Inspector tools. There are more, CommonApi presumably means it will also work on New World.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Invoke-WebRequest -UseBasicParsing -Uri "https://www.paknsave.co.nz/" ` | |
-UserAgent "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0" ` | |
-SessionVariable PaknSave ` | |
-Headers @{ | |
"Accept" = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" | |
"DNT" = "1" | |
} | Out-Null | |
$Stores = Invoke-WebRequest "https://www.paknsave.co.nz/CommonApi/Store/GetStoreList" ` | |
-Method Post ` | |
-UserAgent "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0" ` | |
-UseBasicParsing ` | |
-SessionVariable $PaknSave ` | |
-Headers @{ | |
"Accept" = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" | |
"DNT" = "1" | |
} | |
$StoresList = ($Stores.Content | ConvertFrom-Json).stores | |
$NorthIslandStores = $StoresList | Where-Object { $_.region -eq "NI" } | |
$SouthIslandStores = $StoresList | Where-Object { $_.region -eq "SI" } | |
Write-Host "1) North Island (NI)" | |
Write-Host "2) South Island (SI)" | |
$Region = "" | |
$RegionSelection = Read-Host "Please select your region" | |
if ($RegionSelection -eq "1") { | |
$Region = "NI" | |
$SelectedRegionStores = $NorthIslandStores | |
Write-Host "You selected: North Island (NI)" | |
} elseif ($RegionSelection -eq "2") { | |
$Region = "SI" | |
$SelectedRegionStores = $SouthIslandStores | |
Write-Host "You selected: South Island (SI)" | |
} | |
$Counter = 1 | |
foreach ($Store in $SelectedRegionStores) { | |
Write-Host "$Counter) $($Store.name)" | |
$Counter++ | |
} | |
$StoreSelection = Read-Host "Please select your store by entering the corresponding number" | |
$StoreID = $SelectedRegionStores[$StoreSelection - 1].id | |
Write-Host "You selected: $($SelectedRegionStores[$StoreSelection - 1].name)" | |
Write-Host "Store ID saved: $StoreID" | |
Write-Host "Getting `"Aisle of Value`"" | |
$PaknSave.Cookies.Add((New-Object System.Net.Cookie("eCom_STORE_ID", "StoreID", "/", "www.paknsave.co.nz"))) | |
$PaknSave.Cookies.Add((New-Object System.Net.Cookie("eCom_StoreId_NotSameAs_Brands", "false", "/", "www.paknsave.co.nz"))) | |
$PaknSave.Cookies.Add((New-Object System.Net.Cookie("brands_store_reset", "", "/", "www.paknsave.co.nz"))) | |
$PaknSave.Cookies.Add((New-Object System.Net.Cookie("STORE_ID_V2", "$StoreID|False", "/", "www.paknsave.co.nz"))) | |
$PaknSave.Cookies.Add((New-Object System.Net.Cookie("Region", "$Region", "/", "www.paknsave.co.nz"))) | |
$PaknSave.Cookies.Add((New-Object System.Net.Cookie("AllowRestrictedItems", "true", "/", "www.paknsave.co.nz"))) | |
$ValueItems = Invoke-WebRequest -UseBasicParsing -Uri "https://www.paknsave.co.nz/CommonApi/Checkout/GetAisleOfValueProducts" ` | |
-WebSession $PaknSave ` | |
-UserAgent "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0" ` | |
-Headers @{ | |
"Accept" = "application/json, text/plain, */*" | |
"Accept-Language" = "en-US,en;q=0.5" | |
"Accept-Encoding" = "gzip, deflate, br, zstd" | |
"Referer" = "https://www.paknsave.co.nz/" | |
"DNT" = "1" | |
} | |
$Counter = 1 | |
foreach ($Item in ($ValueItems.Content | ConvertFrom-Json).products) { | |
$Item.name + " is on sale for $" + $Item.price | |
} |
Author
Arefu
commented
Apr 4, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment