-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (31 loc) · 877 Bytes
/
Copy pathindex.js
File metadata and controls
36 lines (31 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { crawlWebsite } = require("./src/crawl");
const { createLocalFolder } = require("./src/fileHandler");
const entryPoint = "https://www.example.com";
//const entryPoint = "https://youtube.com";
const folderPath = createLocalFolder(entryPoint);
// Number of concurrent downloads
const downloadConcurrent = 10;
// Maximum number of pages to download from a website
// Limits big websites with a lot of pages (like youtube.com)
const maxPages = 100;
/**
* Initiating the crawling process.
*/
async function main() {
try {
const pagesDownloaded = await crawlWebsite(
entryPoint,
folderPath,
downloadConcurrent,
maxPages
);
console.log(
`${pagesDownloaded.size} Pages downloaded: ${Array.from(
pagesDownloaded
).join(", ")}`
);
} catch (error) {
console.error(`Error: ${error.message}`);
}
}
main();