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

143
Vistas
How do I scrape a specific website folder programatically in NodeJS?

I'm trying to test a method where I can try scraping files from a specific folder on a website, for example:

The content I want to crawl is in this specific folder: example.com/assets/filename-xxx.js There are 40-50 files such as this but they all have different numbers as the suffix.

How am I able to set a method using NodeJS by conditionally adding in the for loop to add a random number and see if there's a match to download the file, if there isn't a match it will skip and move to the next number, technically this will have to run 999 times at max.

Currently, I'm using website-scraper and the current code

const scrape = require('website-scraper'); 
const websiteUrl = 'http://example.com/assets/'; 
 
scrape({ 
    urls: [websiteUrl], 
    urlFilter: function (url) { 
        return url.indexOf(websiteUrl) === 0; 
    }, 
    recursive: true, 
    maxDepth: 50, 
    prettifyUrls: true, 
    filenameGenerator: 'bySiteStructure', 
    directory: './node-website' 
}).then((data) => { 
    console.log("Entire website succesfully downloaded"); 
}).catch((err) => { 
    console.log("An error ocurred", err); 
}); 

However, this doesn't work because it only follows links, any ideas on a solution?

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

You can try https://pptr.dev/ (Puppeteer)

npm package (https://www.npmjs.com/package/puppeteer)

It works for me

about 4 years ago · Santiago Gelvez 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