var items = []; var userId = (await(await fetch('https://allegro.pl/login/user')).json()).userId; for(;;) { var f = fetch(`https://edge.allegro.pl/sale/offers?seller.id=userId&sellingMode.format=BUY_NOW&publication.status=ACTIVE&limit=1000&offset=${items.length}`, { "headers": { "accept": "application/vnd.allegro.web.v1+json; charset=UTF-8", "accept-language": "pl-PL", "content-type": "application/vnd.allegro.public.v1+json; charset=UTF-8", "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Microsoft Edge\";v=\"90\"", "sec-ch-ua-mobile": "?0", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-site" }, "referrerPolicy": "unsafe-url", "body": null, "method": "GET", "mode": "cors", "credentials": "include" }); var resp = await (await f).json() items = [...items, ...resp.items]; await new Promise(r => setTimeout(r, 1000)); if(resp.totalItems <= items.length) break; } (function(console){ console.save = function(data, filename){ if(!data) { console.error('Console.save: No data') return; } if(!filename) filename = 'console.json' if(typeof data === "object"){ data = JSON.stringify(data, undefined, 4) } var blob = new Blob([data], {type: 'text/json'}), e = document.createEvent('MouseEvents'), a = document.createElement('a') a.download = filename a.href = window.URL.createObjectURL(blob) a.dataset.downloadurl = ['text/json', a.download, a.href].join(':') e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null) a.dispatchEvent(e) } })(console) toSave = items.map(x=>`${x.offerId};${x.offerTitle};${x.buyNowPrice.amount.toString().replace('.',',')};${x.inSaleAmount}`); toSave.unshift('ID;Tytuł;Cena;Ilość'); console.save(toSave.join('\r\n'), 'allegro.csv')