Created
February 25, 2011 07:49
-
-
Save mmichelli/843496 to your computer and use it in GitHub Desktop.
get json ski results
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
var http = require('http'); | |
var google = http.createClient(80, 'www.nrk.no'); | |
var request = google.request('GET', '/contentfile/web/files/sport/json/medaljer_skivm_2011.js', {'host': 'www.nrk.no'}); | |
request.end(); | |
var out = ''; | |
request.on('response', function (response) { | |
response.setEncoding('utf-8'); | |
response.on('data', function (chunk) { | |
out += chunk.toString("utf8"); | |
console.log("-------------------" + chunk) | |
}); | |
response.on('end', function (chunk) { | |
out = out.replace(/\t/mg, '').replace(/\n/mg, ''); | |
console.log("--" ); | |
console.log(out ); | |
console.log(JSON.parse(out)); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
r":1,"bronze":0,"t
^^
SyntaxError: Unexpected token ILLEGAL
at Object.parse (native)
at IncomingMessage. (/Users/Mario Michelli/Sites/skivm/rank.js:19:26)
at IncomingMessage.emit (events.js:59:20)
at HTTPParser.onMessageComplete (http.js:111:23)
at Client.onData as ondata
at Client._onReadable (net.js:654:27)
at IOWatcher.onReadable as callback