We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Max Pages

As it stands, our crawler is only useful on fairly small sites. Sites with thousands or hundreds of thousands of pages take too long to crawl.

Google's crawlers run concurrently on fleets of servers to crawl the majority of the internet. You might not have that kind of budget for this project.

Let's add a maxPages setting so that we can crawl even gigantic websites and have our tool automatically stop when it's done a reasonable amount of work.

Assignment

      • Set shouldStop = true
      • Print "Reached maximum number of pages to crawl."
      • Return false
  1. # usage: npm run start <URL> <maxConcurrency> <maxPages>
    npm run start https://learnwebscraping.dev/practice/ecommerce/ 3 10
    

Make sure that your program prints a line to the console each time you crawl a page, as well as once per page in the report. This will help you see what your crawler is doing, and ensure you can kill it with Ctrl+C if it's stuck in a loop or spamming requests.

Run and submit the CLI tests.