0

how can I convert this script from puppeteer to puppeteer cluster

const URL = process.argv[2];
puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] }).then(async browser => {
    const page = await browser.newPage();
    await page.setViewport({width: 1, height: 1});
    await page.setUserAgent('Mozilla/5.0 (iPhone; CPU iPhone OS 9_0_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13A404 Safari/601.1');
    await page.goto(URL);
    console.error('found');
    await page.waitForSelector('body.blog');
    await browser.close();
    process.exit();
}).catch(function(error) {
    console.error('sucess');
    process.exit();
});
  • Can you take a look at the answer? the example I have posted shows pretty much a standard implementation of queueing tasks on a puppeteer-cluster congruent with the library's documentation. We can't convert it for you, but you asked how, and the example shows how. – Peyter Jan 16 '20 at 16:30

1 Answers1

0

When you make the cluster, you queue up tasks which are essentially functions that the cluster will try to execute in the order you specify.

I have an open question here which you can use to learn the structure of the cluster queue. But definitely recommend you also re-read TD's documentation on the Github

And if anyone is feeling generous and could help me with my question...I'm still trying to run tests to figure it out...

Peyter
  • 474
  • 3
  • 14