Created
September 6, 2014 18:08
-
-
Save jquense/8017e71e4d7ce19827ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
request('http://ugenr.dk/', function (error, response, html) { | |
if (!error && response.statusCode == 200) { | |
var $ = cheerio.load(html); | |
$('span#ugenr').each(function(i, element){ | |
var ugeNr = $(this).text(); | |
ugeNr = ugeNr.split(" "); | |
ugeNr = ugeNr[1] | |
request('http://skema1.domain.com/services/elevSkema.ashx?idx=randomNumber&week='+ugeNr, secondCallback); | |
}); | |
} | |
}); | |
function secondCallback(error, response, html) { | |
if (!error && response.statusCode == 200) { | |
var $ = cheerio.load(html); | |
$('div#uge36').each(function(i, element){ | |
var elev = $(this).children(".titledata").text(); | |
var elevSchema = mongoose.Schema({ | |
name: String | |
}) | |
var Pupil = mongoose.model('Pupil', elevSchema) | |
var navn = new Pupil({ name: elev }) | |
navn.save(function (err, navn) { | |
if (err) return console.error(err); | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment