Answer the question
In order to leave comments, you need to log in
How to run multiple threads with Puppeter in node js?
First - I need to open several windows with Puppeter, for this - I call the function through a loop, with different parameters. After that - the function sends a couple of requests and after - calls this function with Puppeter
function startPup(){
(async () => {
const browser = await puppeteer.launch()
const page = await browser.newPage();
await page.goto('https://...');
await page.addScriptTag({path: 'script.js'});
try{
await page.waitForSelector('#name')
html = await page.content()
console.log(html )
await browser.close();
}
catch{
console.log(html)
await browser.close();
}
})()
}
Answer the question
In order to leave comments, you need to log in
QUEUES will help you :) . There are even dedicated solutions for Puppeter - https://github.com/thomasdondorf/puppeteer-cluster .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question