Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onOpen(){
- SpreadsheetApp.getUi()
- .createMenu("๐ฑ")
- .addItem("ะทะฐะฟัััะธัั!", "myFunction")
- .addToUi();
- }
- function myFunction() {
- const ss = SpreadsheetApp.getActive();
- const sh = ss.getSheetByName("ะะธัั1");
- const nmIds = sh.getDataRange().getValues().slice(1);
- const data = nmIds.map(row => {
- const nmId = row[0];
- const url = getJsonUrl(nmId);
- const r = JSON.parse(UrlFetchApp.fetch(url));
- row = [
- url, r.imt_name, r.subj_name, r.subj_root_name, r.vendor_code, r.season, r.description,
- r?.options.map(f => f.name + ": " + f.value).join('\n'),
- r?.grouped_options.map(ff => ff.options.map(fff => ff.group_name + ", " + fff.name + ": " + fff.value).join('\n')).join('\n')
- ];
- return row;
- });
- sh.getRange("B2:" + data.length).clearContent();
- sh.getRange(2, 2, data.length, data[0].length).setValues(data);
- };
- function getJsonUrl(nmid) {
- const basket = {
- 143: '01',
- 287: '02',
- 431: '03',
- 719: '04',
- 1007: '05',
- 1061: '06',
- 1115: '07',
- 1169: '08',
- 1313: '09',
- 1601: '10',
- 1655: '11',
- 1919: '12',
- 2045: '13',
- 99999: '14'
- }
- return `https://basket-${basket[Object.keys(basket)
- .filter(v => Math.floor(nmid / 100000) <= v)[0]]}.wb.ru/vol${Math.floor(nmid / 100000)}/part${Math.floor(nmid / 1000)}/${nmid}/info/ru/card.json`
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement