24 lines
495 B
JavaScript
24 lines
495 B
JavaScript
#!/usr/bin/env node
|
|
const CronJob = require('cron').CronJob;
|
|
|
|
// load env variables from file
|
|
require('dotenv').config();
|
|
|
|
const Portugal = require('./ncas/pt');
|
|
|
|
async function run() {
|
|
const ptScraper = new Portugal();
|
|
|
|
if (typeof(process.env.PT_CRON) === 'string' )
|
|
new CronJob(process.env.PT_CRON, async function() {
|
|
await ptScraper.run();
|
|
}, null, true);
|
|
|
|
if (process.env.SCRAPE_START === ptScraper.id)
|
|
await ptScraper.run();
|
|
|
|
console.log('PT Launched');
|
|
}
|
|
|
|
run();
|