Last active
May 1, 2024 15:15
-
-
Save perfaram/ff040e7d5cc2a2ac4d8901663fad93b3 to your computer and use it in GitHub Desktop.
dump product descriptions for all products in the "pasta" category sold at Migros (Switzerland)
This file contains hidden or 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
import pkg from 'migros-api-wrapper'; | |
const { MigrosAPI, ILoginCookies } = pkg; | |
import fs from 'fs'; | |
main(); | |
async function main() { | |
// Search for products matching a certain string. | |
const guestInfo = await MigrosAPI.account.oauth2.getGuestToken(); | |
const responseCategoryList = await MigrosAPI.products.productSearch.category({ | |
categoryId: 7494976, | |
//from: 100 // for pagination | |
}, { leshopch: guestInfo.token }) | |
const productCards = await MigrosAPI.products.productDisplay.getProductCards({ | |
uids: responseCategoryList["productIds"] | |
}, { leshopch: guestInfo.token }) | |
const migrosIds = productCards.map((card) => { | |
return card["product"]["migrosId"] | |
}) | |
const productDetails = await MigrosAPI.products.productDisplay.getProductDetails({ | |
migrosIds: migrosIds | |
}, { leshopch: guestInfo.token }) | |
fs.writeFile("test.json", JSON.stringify(productDetails), function(err) { | |
if (err) { | |
console.log(err); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(Depends on https://github.com/perfaram/migros-api-wrapper)