taptap/src/app.js
2019-10-08 17:52:49 +08:00

38 lines
871 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import mongoose from 'mongoose'
import schedule from 'node-schedule'
import config from '../config/config'
import getCate from './spider/cate'
const db = mongoose.connection
db.on('error', function(err) {
console.log(err)
process.exit(1)
})
db.once('open', function() {
console.log('Connected to db.')
})
mongoose.connect(config.db_taptap, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
const scheduleCronstyle = () => {
console.log('TapTap爬虫正在运行')
const timer = schedule.scheduleJob('0 0 10 * * *', () => {
console.log(new Date() + '开始收集数据!')
getAllData()
})
}
scheduleCronstyle()
function getAllData() {
setTimeout(getCate, 0, 'download')
setTimeout(getCate, 1200000, 'new')
setTimeout(getCate, 2400000, 'reserve')
setTimeout(getCate, 3600000, 'sell')
setTimeout(getCate, 4800000, 'played')
}