Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!