← back to Designer Wallcoverings
_incr.mjs
21 lines
import { chromium } from 'playwright';
const URL='https://www.designerwallcoverings.com/collections/new-arrivals?preview_theme_id=143953264691';
const b=await chromium.launch(); const p=await (await b.newContext({viewport:{width:1440,height:1000}})).newPage();
await p.goto(URL,{waitUntil:'domcontentloaded',timeout:60000});
await p.waitForSelector('.boost-sd__product-list',{timeout:30000}); await p.waitForTimeout(3000);
const count=()=>p.evaluate(()=>document.querySelectorAll('.boost-sd__product-item').length);
let log=[await count()];
// incremental human-like scroll
for(let i=0;i<14;i++){
await p.evaluate(()=>window.scrollBy(0, Math.round(window.innerHeight*0.85)));
await p.waitForTimeout(1200);
log.push(await count());
}
// also try clicking the load-more button if present
const btn=await p.$('.boost-sd__pagination-infinite-scroll-container-button, [class*="load-more"] button, [class*="loadmore"]');
let clicked=false;
if(btn){ try{ await btn.click(); clicked=true; await p.waitForTimeout(2000);}catch(e){} }
log.push('afterClick='+(clicked?await count():'noBtn'));
console.log('product counts over scroll:', JSON.stringify(log));
await b.close();