Skip to content

Instantly share code, notes, and snippets.

@perfaram
Last active May 1, 2024 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perfaram/ff040e7d5cc2a2ac4d8901663fad93b3 to your computer and use it in GitHub Desktop.
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)
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);
}
});
}
@perfaram
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment