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

361
Visualizações
Render Puppeteer browser from server to client

I'm trying to provide remote access of puppeteer browser to the client so that I can trace the user activities. Using Socket.io, capturing mouse events and taking screenshots of the browser, I was able to render the browser to the client like this:

const launchBrowser = async (socket) => {
    try {
        browser = await puppeteer.launch({defaultViewport: null, args: minimal_args});

        browser.on("disconnected", () => {
            clearInterval(interval);
        });

        let page = await browser.pages();
        page = page[0];
        console.log("connected")
        await page.setViewport({
            width: 800,
            height: 600
        });

        await page.goto("https://example.com/", {waitUntil: "networkidle0", timeout: 0});

        socket.on('MOUSE_MOVE', async ({x, y}) => {
            await page.mouse.move(x, y);
        });

        socket.on('MOUSE_CLICK', async ({x, y, button}) => {
            await page.mouse.click(x, y, {button: button});
        });

        socket.on('KEY_PRESS', async ({key}) => {
            if (key === "ArrowUp") {
                await page.mouse.wheel({deltaY: -100});
                return
            }
            if (key === "ArrowDown") {
                await page.mouse.wheel({deltaY: 100});
                return
            }
            await page.keyboard.press(key);
        });

        socket.on('WHEEL', async ({x, y}) => {
            await page.mouse.wheel({deltaX: x, deltaY: y});
        });

        //taking continuous screen shots and broadcasting it to the client
        interval = setInterval(async () => {
            try {
                const ss = await page.screenshot({encoding: "base64", captureBeyondViewport: false});
                socket.emit("receive-screen", ss);
            } catch (e) {
                console.log(e.message);
            }
        }, 1);


    } catch (e) {
        console.log(e);
    }
}

But, this way of taking screenshots and broadcasting isn't smooth and doesn't provide a good user experience. I also tried recording the browser using puppeteer-stream and streaming it to the client but the video streams with around 3-4 seconds delay.

Is there any way to make the broadcasting of screenshots smooth or any other way to render the puppeteer browser to the client to provide remote access?

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