1

Saw plenty of examples of puppeteer-cluster and how to instantiate it/create tasks by reading the documentation in its GitHub page, yet I can't still figure out how to import the same instance of puppeteer-cluster across different files of my application, to take advantage of it

Can I import an unique puppeter-cluster instance and its tasks in other files of my application, and queue them from it?

Sergio Palmeiras
  • 221
  • 4
  • 13

1 Answers1

0

I did something like this

init-puppeteer-cluster.js

let cluster;
const init = async () => {
 cluster = await Cluster.launch(....)
 await cluster.task(....)
}
export {init,cluster}

In app.js init()

In other files cluster.queue(...)

Yusuf
  • 321
  • 1
  • 7
  • 19