UNPKG

ui-studentsearch

Version:

API for majapahit.cs.ui.ac.id/studentsearch

25 lines (24 loc) 601 B
var scrape = require('scrape-it'); var base = 'http://majapahit.cs.ui.ac.id/studentsearch/index.php'; var criteria = { students: { listItem: 'tbody tr', data: { name:'td:nth-of-type(1) a', npm: 'td:nth-of-type(2)', email: 'td:nth-of-type(3)', faculty: 'td:nth-of-type(4)' } } }; /** * Search for term * @param {String} term search term * @param {Function} done callback(error, result) * @return {Object} array of student object */ module.exports = function(term, done) { scrape(base + '?s=' + term, criteria, (err, result) => { done(err, result.students); }); }