简体   繁体   English

如何将此 Puppeteer 脚本转换为 Puppeteer 集群

[英]how to convert this Puppeteer script to Puppeteer cluster

how can I convert this script from puppeteer to puppeteer cluster如何将此脚本从 puppeteer 转换为 puppeteer 集群

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();
});

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但绝对建议您也重新阅读 TD 在 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...如果有人感到慷慨并且可以帮助我解决我的问题......我仍在尝试进行测试以弄清楚......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM