-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
22 lines (19 loc) · 677 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const puppeteer = require('puppeteer')
const Crawler = require('./lib/crawler')
// `;` is a syntax error guard :P
;(async () => {
const browser = await puppeteer.launch()
let db = await require('mongodb').MongoClient.connect('mongodb://localhost:27017/fudanbbs')
db = db.db('fudanbbs')
console.log('connected to mongodb')
let crawler = new Crawler({ db, browser })
let boards = await crawler.getAllBoards()
// TODO: parallelism
for (let board of boards) {
await crawler.updateBoardByName(board)
}
await browser.close()
// I don't know why I am doing this
// plz let me know if you can exit successfully without this line :(
process.exit(0)
})()