Removed redundant comments and made the file a module.
This commit is contained in:
parent
5f9348876f
commit
d5b63d1baa
|
@ -1,10 +1,8 @@
|
||||||
//Import/require modules needed to crawl the schoolmaster schedules.
|
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
var cheerio = require('cheerio');
|
var cheerio = require('cheerio');
|
||||||
var iconv = require('iconv-lite');
|
var iconv = require('iconv-lite');
|
||||||
var mongodb = require('mongodb').MongoClient;
|
var mongodb = require('mongodb').MongoClient;
|
||||||
|
|
||||||
//Define schooltypes that need to be ripped.
|
|
||||||
var scheduletypes = [
|
var scheduletypes = [
|
||||||
'Klasrooster',
|
'Klasrooster',
|
||||||
'Docentrooster',
|
'Docentrooster',
|
||||||
|
@ -19,9 +17,9 @@ function get(database) {
|
||||||
var collection = database.collection('index');
|
var collection = database.collection('index');
|
||||||
collection.drop();
|
collection.drop();
|
||||||
|
|
||||||
//Go past all of the scheduletypes and download their pages.
|
|
||||||
for (scheduletype of scheduletypes) {
|
for (scheduletype of scheduletypes) {
|
||||||
(function (scheduletype) {
|
(function (scheduletype) {
|
||||||
|
|
||||||
var link = 'http://roosters5.gepro-osi.nl/roosters/rooster.php?school=' + schoolid + '&type=' + scheduletype;
|
var link = 'http://roosters5.gepro-osi.nl/roosters/rooster.php?school=' + schoolid + '&type=' + scheduletype;
|
||||||
|
|
||||||
scheduletype = scheduletype.replace(/rooster/g, '').toLowerCase();
|
scheduletype = scheduletype.replace(/rooster/g, '').toLowerCase();
|
||||||
|
@ -109,6 +107,7 @@ function crawl(sid) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Redundant function for draining native-mongodb-driver output
|
||||||
function showOutput(error, message) {
|
function showOutput(error, message) {
|
||||||
if (process.argv[2] == '-v') {
|
if (process.argv[2] == '-v') {
|
||||||
if (error) process.stdout.write(error.toString());
|
if (error) process.stdout.write(error.toString());
|
||||||
|
@ -116,4 +115,6 @@ function showOutput(error, message) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
crawl(934);
|
module.exports = {
|
||||||
|
'crawl' : crawl
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue