I have the following code:
const puppeteer = require('puppeteer');
const cheerio = require('cheerio');
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(<my_url>, { waitUntil: 'networkidle0' });
// Get the content of the first page
const page1 = await page.content();
let $ = cheerio.load(page1);
let items = $($('div[id*=document]')).toArray();
// Go to another page
const buttonToPage2 = await page.$('li[data-page="2"]');
await buttonToPage2.click();
// Get the content from the second page
const page2 = await page.content();
let $ = cheerio.load(page2);
items = items.concat($($('div[id*=document]')).toArray());
Doesn't it make sense? It seems I'm not getting the right content from the page 2. Anyway, do you know a better way to reach that?