Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

553
Vistas
How to change the name of a file before it downloads in Puppeteer?

I need to download several .csv files from a website and save them with different names. However, they all download with the same name. And therefor, they keep overwriting the last one, leaving me with just one file at the end. Here's my code:

for(let i = 0; i <= 10; i++){
await page._client.send("Page.setDownloadBehavior", {
            behavior: "allow",
            downloadPath: `./csvFiles/`,
        });
await page.click("button_selector");
}

The download starts after Puppeteer clicks the download button, and since all this code is in a loop, I can't rename the files because they are only created after the loop is over, by which time I only have one file downloaded.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If the URLs of the CSV files can be obtained, you could insert (or modify) the download attribute of the <a> tag.

Otherwise, you could possibly intercept the server's HTTP response and modify the Content-Disposition response header to set a filename so the browser receives an altered HTTP response with the explicit filename.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda