const request = require('request'); request('https://www.cmlab.csie.ntu.edu.tw/status/', function (error, response, body) { console.log(body) // Show the HTML });
// require modules let deadMachines = []; request('http://www.cmlab.csie.ntu.edu.tw/status/', function (err, res, body) { const $ = cheerio.load(body); const dead = $('.dead'); for (let i = 0; i < dead.length; i++) { const machineId = dead.eq(i).text(); deadMachines.push(machineId); } // all machines are fine~ if (!deadMachines.length) return; // login to facebook and send msg to unix manager loginFacebook(config.account, function (err, api) { if (err) returnconsole.error(err); api.sendMessage(`${deadMachines.toString()} is dead.`, /* channel_id */, function (err) { console.log(`${deadMachines.toString()} is dead.`); }); }); });