使用节点的请求获取RSS提要

时间:2014-07-07 14:55:42

标签: javascript json angularjs mongodb rss

我目前正在使用节点的请求包(https://github.com/mikeal/request)从iTunes App Store审核链接获取http内容并抓取它以获取评论。

我注意到iTunes有一个RSS提要可用于获取应用的客户评论,这似乎更适合使用。如何使用请求从RSS提要(以及MongoDB中的可能存储)获取JSON数据?是否有更好的选择,例如将RSS提要数据直接加载到AngularJS中?

问题是我的localhost / appstore尝试重定向到RSS提要阅读器。我只需要从请求中获取JSON数据。以下是使用请求的代码片段。

app.get('/appstore', function(req, res) {

  var options = {
    url: 'https://itunes.apple.com/us/rss/customerreviews/id=662900426/sortBy=mostRecent/json',
    json: true,
    headers: {
      'User-Agent': 'request'
    }
  };

  function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
      var info = JSON.parse(body);
      console.log(info);
    }
  }

  request(options, callback);

});

0 个答案:

没有答案