Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

145
Visualizações
Speeding up Puppeteer Operations

I am currently trying to speed up my server, which uses puppeteer to scrape information whenever it receives requests from a chrome extension I am building. However, it is still quite slow despite me trying to run it concurrently. Is there a way to keep my puppeteer browser open once my server starts, so I can shave off the time it takes to open the browser each time a request is sent?

const withBrowser = async (fn) => {
    const browser = await puppeteer.launch({args: ['--no-sandbox']});
    try {
        return await fn(browser); }
    finally {
        await browser.close();
    }
}

const withPage = (browser) => async (fn) => {
    const page = await browser.newPage();
    // await page.setDefaultNavigationTimeout(0);
    // await page.setCacheEnabled(false);
    try {
        return await fn(page);
    } finally {
        await page.close();
    }
}

async function processing(urls){ 

    return await withBrowser(async (browser) => {
    return bluebird.map(urls, async (url) => {
        return withPage(browser)(async (page) => {
            await page.goto(url);
            let texts = await page.evaluate(() => {
                let data = [];
                // do work
            }
            return ["0000"];
        }
        );
    }, {concurrency: 4});
});
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda