Closed webmip closed 1 year ago
Already fixed. Let me put the code here just in case works for someone:
´´´ app.get('/run-instance/xxxx', async (req, res) => { const { id } = req.params;
const cluster = await Cluster.launch({
concurrency: Cluster.CONCURRENCY_CONTEXT,
maxConcurrency: 1, // run only one instance
timeout: 100000, // 100sec
monitor: true,
puppeteer,
puppeteerOptions: {
headless: false,
ignoreHTTPSErrors: true,
defaultViewport: false,
//slowMo: 1000,
args: [
'--proxy-server=xxxxx',
'--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36',
'--disable-site-isolation-trials',
'--disable-features=site-per-process,SitePerProcess',
'--disable-blink-features=AutomationControlled',
'--disable-web-security'
],
},
});
cluster.queue(TARGET_URI, name);
await cluster.idle();
await cluster.close();
res.send(`Instance ${id} completed!`);
});
´´´
Let's say something like that. I need the code using puppeteer-cluster to call the same url (http://google.vom) at the same time (in parallel) but on each instance perform a different action. And in order to call my actions I want to use express to create a simple api who allow me to run one instance of the cluster individually or all at the same time.
Example I have logic1.js and logic2.js
I would like to ru call http://localhost.com/api/1 and execute logic1.js or call http://localhost.com/all and execute logic1.js and logic2.js at the same time.
I have something like that but is not working properly
Thanks