-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (28 loc) · 1006 Bytes
/
index.js
File metadata and controls
33 lines (28 loc) · 1006 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
const getWallstreetNews = require('./lib/getWallstreetNews')
const getWallstreetArticle = require('./lib/getWallstreetArticle')
const getWallstreetNewsAndArticle = require('./lib/getWallstreetNewsAndArticle')
const { newsTypes } = require('./global/config')
// getWallstreetNews.start()
// getWallstreetArticle.start('/articles/3438434')
// getWallstreetNewsAndArticle.start()
const args = (process.argv.slice(2))
let newsType = newsTypes[0].name
let numOfRecord = 5
// 第一個參數判斷
if (args[0]) {
const newsTypeNames = newsTypes.map(newsType => newsType.name)
if (newsTypeNames.indexOf(args[0]) === -1) {
console.log(`First argument options: [${newsTypes.toString()}]`)
return
}
newsType = args[0]
}
// 第二個參數判斷
if (args[1]) {
if (isNaN(args[1])) {
console.log(`Second argument is number of record you want to scrape.`)
return
}
numOfRecord = Number(args[1])
}
getWallstreetNewsAndArticle.start(newsType, numOfRecord)