попробуйте это:
app.get('/testing',function(req,res){
(async () => {
const browser = await puppeteer.launch({
headless: true
});
const page = await browser.newPage();
await page.goto('https://www.tapology.com/regions',{waitUntil: 'domcontentloaded'});
const example = await page.$('.regionIndex');
const scrapedData = await page.evaluate(() =>
Array.from(document.querySelectorAll('h4 a'))
.map(link => ({
title: link.innerHTML,
link: link.getAttribute('href')
}))
)
console.log('scrapedData',scrapedData);
await page.close();
await browser.close();
return res.send(scrapedData);
})();
});
вы получите:
[
{
title: "US Midwest",
link: "/regions/us-midwest"
},
{
title: "US Northeast",
link: "/regions/us-northeast"
},
{
title: "US Southeast",
link: "/regions/us-southeast"
},
{
title: "US Southwest",
link: "/regions/us-southwest"
},
{
title: "US West",
link: "/regions/us-west"
},
{
title: "Asia Central",
link: "/regions/central-asia"
},
{
title: "Canada",
link: "/regions/canada"
},
{
title: "Europe Balkans",
link: "/regions/europe-balkans"
},
{
title: "Europe Eastern",
link: "/regions/europe-eastern"
},
{
title: "Europe Western",
link: "/regions/western-europe"
},
{
title: "Latin America",
link: "/regions/latin-america"
},
{
title: "Middle East",
link: "/regions/middle-east"
}
]