Write less code
In Puppeteer or Playwright you write the mechanics yourself: waitForSelector, $$eval, click next, wait, loop. A step is that sequence already written. Pass it what it needs: click takes the button selector, scrape takes the data selector, the next-page selector, and a result count. A dozen lines come out as one.