-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
36 lines (31 loc) · 887 Bytes
/
main.js
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
(async () => {
const yargs = require('yargs')
const Scraper = require('./utils/scraper')
const argv = yargs(process.argv.slice(2))
.command('start', 'start scrape', async (_argv) => {
const {url, browser, regexp, v = false} = _argv.argv
if(!url) {
throw new Error('[ERROR] --url needed')
}
const scr = new Scraper(url , {
isBrowser: browser,
regexp,
isLog: v
})
await scr.process()
})
.option('url', {
type: 'string',
description: 'The url of the page that is going to scrape'
})
.option('regexp', {
type: 'string',
description: 'The regular expression that all the links should match'
})
.option('verbose', {
alias: 'v',
type: 'boolean',
description: 'Run with verbose logging'
})
.argv;
})()