node.js streaming finance data from Yahoo or Google
UPDATE: I want to continuously receive data. Currently, this returns one data set. I think the onl开发者_JS百科y alternative is polling/setInterval techniques that achieve only the effect of streaming.
Is it possible to retrieve streaming finance data from Yahoo or Google using node.js?
I know that they have no public API available for the data I'm trying to retrieve.I've written this using express but the data is not streaming.
var express = require('express'),
http = require('http'),
app = express.createServer();
// Using either Google or Yahoo...
var client = http.createClient(80,'download.finance.yahoo.com');
var request = client.request('GET', '/d/quotes.csv?s=GOOG&f=snr', { host: 'download.finance.yahoo.com' });
//var client = http.createClient(80,'www.google.com');
//var request = client.request('GET', '/finance/info?client=ig&q=CSCO', { host: 'www.google.com'});
request.end();
request.addListener('response', function (response) {
response.setEncoding(encoding="utf8");
response.addListener('data', function (data) {
console.log(data);
});
response.addListener('end',function(data) {
console.log('End');
});
});
app.listen(8080);
精彩评论