const puppeteer = require('C:/xampp/htdocs/vilmax/vilmax-cockpit/node_modules/puppeteer'); const URL = 'https://bazarowy-swiat.pl/produkt/naroznik-oskar-tilia-warianty-l-p/?v=' + Date.now(); (async () => { const browser = await puppeteer.launch({ headless: 'new', args: ['--ignore-certificate-errors'] }); const page = await browser.newPage(); await page.setViewport({ width: 1440, height: 1000 }); page.on('console', m => { if (m.type() === 'error') console.log('CONSOLE-ERR:', m.text().slice(0,120)); }); await page.goto(URL, { waitUntil: 'networkidle2', timeout: 90000 }); await new Promise(r => setTimeout(r, 3000)); // zaakceptuj cookies jesli jest await page.evaluate(() => { const b = [...document.querySelectorAll('button,a')].find(x => /akceptuj|zgadzam/i.test(x.innerText) && x.offsetParent); if (b) b.click(); }); await new Promise(r => setTimeout(r, 1000)); const gal = () => page.evaluate(() => [...document.querySelectorAll('.woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image img')] .map(i => i.getAttribute('src').split('/').pop().slice(0,12)).join(',')); console.log('INIT :', await gal()); // wybierz odcien TILIA 77 (granat) — kliknij swatch albo select await page.select('select[data-attribute_name="attribute_pa_kod-odcienia"]', '77'); await new Promise(r => setTimeout(r, 2500)); console.log('T77 :', await gal()); await page.screenshot({ path: 'gal_full_t77.png' }); // wybierz strone prawy await page.select('select[data-attribute_name="attribute_pa_strona"]', 'prawy'); await new Promise(r => setTimeout(r, 2500)); console.log('P77 :', await gal()); await page.screenshot({ path: 'gal_full_p77.png' }); // zmien odcien na 100 (czarny) await page.select('select[data-attribute_name="attribute_pa_kod-odcienia"]', '100'); await new Promise(r => setTimeout(r, 2500)); console.log('P100 :', await gal()); await page.screenshot({ path: 'gal_full_p100.png' }); // reset await page.evaluate(() => { const b=document.querySelector('.reset_variations'); if(b) b.click(); }); await new Promise(r => setTimeout(r, 2500)); console.log('RESET:', await gal()); await browser.close(); })().catch(e => console.error('ERR', e.message));