Made ids an integer and made -v option better.
Made running from cli an option.
This commit is contained in:
parent
d5b63d1baa
commit
99d80da6d5
12
spider.js
12
spider.js
|
@ -51,7 +51,7 @@ function get(database) {
|
||||||
for (student in list_students) {
|
for (student in list_students) {
|
||||||
if (!isNaN(student)) {
|
if (!isNaN(student)) {
|
||||||
var name = cheerio(list_students[student]).text().split(' - ')[1];
|
var name = cheerio(list_students[student]).text().split(' - ')[1];
|
||||||
var id = cheerio(list_students[student]).val();
|
var id = parseInt(cheerio(list_students[student]).val());
|
||||||
|
|
||||||
var database_entry = {
|
var database_entry = {
|
||||||
'id' : id,
|
'id' : id,
|
||||||
|
@ -109,12 +109,16 @@ function crawl(sid) {
|
||||||
|
|
||||||
//Redundant function for draining native-mongodb-driver output
|
//Redundant function for draining native-mongodb-driver output
|
||||||
function showOutput(error, message) {
|
function showOutput(error, message) {
|
||||||
if (process.argv[2] == '-v') {
|
if (process.argv[3] == '-v') {
|
||||||
if (error) process.stdout.write(error.toString());
|
// if (error) process.stdout.write(error.toString());
|
||||||
process.stdout.write(message + '\n');
|
if (message != null) console.log(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
'crawl' : crawl
|
'crawl' : crawl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.argv[2] == 'test') {
|
||||||
|
module.exports.crawl(934);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue