来自雅虎或谷歌的node.js流媒体财务数据

时间:2011-04-18 15:52:03

标签: node.js streaming finance express

更新:我想继续接收数据。目前,这将返回一个数据集。我认为唯一的选择是polling / setInterval技术,它们只能实现流式传输的效果。

是否可以使用node.js从Yahoo或Google检索流媒体财务数据? 我知道他们没有公共API可用于我正在尝试检索的数据。

我使用express编写了这个,但数据不是流式传输。

    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);

0 个答案:

没有答案
相关问题