0

Good afternoon devs, I have a problem. Do not make puppeteer browse sites that are in an array list. Example:

const array = ['www.one.com','www.two.com','www.three.com'];

  Promise.all(
array.map(async index){
await page.goto(index)
}
  );

It does not navigate, it gives an error and closes the browser, but when I do it outside of an array it works. Example:

await page.goto("www.one.com")
await page.goto("www.two.com")
await page.goto("www.three.com")

But I need puppeteer to go through the links within the array.

  • Using `Promise.all` runs the code in parallel, so you're asking Puppeteer to navigate to 3 pages at the same time using the same page (tab). You either need to spawn new pages or use a `for` loop. Please see [this answer](https://stackoverflow.com/a/65000065/6243352). – ggorlen Feb 06 '23 at 15:55

0 Answers0