Skip to content

Instantly share code, notes, and snippets.

@mmichelli
Created February 25, 2011 07:49
Show Gist options
  • Save mmichelli/843496 to your computer and use it in GitHub Desktop.
Save mmichelli/843496 to your computer and use it in GitHub Desktop.
get json ski results
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));
});
});
@mmichelli
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment