-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (32 loc) · 1.05 KB
/
index.js
File metadata and controls
37 lines (32 loc) · 1.05 KB
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
37
let prompt = require('./prompt-promise');
let Crawler = require("./Crawler");
let WikiPage = require("./WikiPage");
let regexp = /\/wiki\/(?!.*:)(.*?)/;
let props = [
{
name: 'FirstPage',
validator: regexp,
warning: 'The link should begin with /wiki/ and everything that follows. Anything before that is not needed.'
},
{
name: 'SecondPage',
validator: regexp,
warning: 'The link should begin with /wiki/ and everything that follows. Anything before that is not needed.'
}
]
let pages = new Set();
prompt.start();
console.log('Please provide 2 pages from Wikipedia that should be the root for the crawler. Input should begin with /wiki/ and everything that follows. Anything before that is not needed');
prompt.get(props)
.then((res) => {
console.log('You have selected the following pages:');
console.log(res.FirstPage);
console.log(res.SecondPage);
for (const page in res) {
if (res.hasOwnProperty(page)) {
pages.add(new WikiPage(res[page]));
}
}
let c = new Crawler(pages);
c.crawl();
});