已超出Google趋势API npm配额

时间:2016-08-23 18:12:58

标签: node.js npm fs google-trends

我正在使用Google Trends API获取历史趋势数据。我正在从CSV文件中读取关键字并触发谷歌趋势查询。 这是代码

var googleTrends = require('google-trends-api');
var fs = require('fs')
fs.readFile('merged.csv', 'utf8', function (err,data) {
        if (err) {
                return console.log(err);
        }
        data = data.toString().split("\n");
        recur(0, data);
});

function recur(index, data){
        if (index < data.length){
                var keyword = data[index].split(",")[0];
                console.log(keyword);
                googleTrends.trendData(keyword)
                .then(function(results){
                        console.log(results);
                        index = index+1;
                        recur(index, data);
                })
                .catch(function(err){
                        console.error('We have an error!', err);
                });
        }
}

我在

之间多次出现此错误
[ Error: Quota limit exceeded, try again later
      at parseJSON (/Users/shubhamjindal/Development/domain-info/node_modules/google-trends-api/lib/resources/htmlParser.js:48:9)
      at /Users/shubhamjindal/Development/domain-info/node_modules/google-trends-api/lib/utils/trendData.js:26:11
      at tryCatcher (/Users/shubhamjindal/Development/domain-info/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/Users/shubhamjindal/Development/domain-info/node_modules/bluebird/js/release/promise.js:504:31)
      at Promise._settlePromise (/Users/shubhamjindal/Development/domain-info/node_modules/bluebird/js/release/promise.js:561:18)
      at Promise._settlePromise0 (/Users/shubhamjindal/Development/domain-info/node_modules/bluebird/js/release/promise.js:606:10)
      at Promise._settlePromises (/Users/shubhamjindal/Development/domain-info/node_modules/bluebird/js/release/promise.js:685:18)
      at Async._drainQueue (/Users/shubhamjindal/Development/domain-info/node_modules/bluebird/js/release/async.js:138:16)
      at Async._drainQueues (/Users/shubhamjindal/Development/domain-info/node_modules/bluebird/js/release/async.js:148:10)
      at Immediate.Async.drainQueues (/Users/shubhamjindal/Development/domain-info/node_modules/bluebird/js/release/async.js:17:14)
      at runCallback (timers.js:570:20)
      at tryOnImmediate (timers.js:550:5)
      at processImmediate [as _immediateCallback] (timers.js:529:5) ]

有人可以建议我解决此错误吗?

0 个答案:

没有答案