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

144
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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