【发布时间】:2017-07-18 21:10:50
【问题描述】:
我正在使用 twit 模块在 twitter 上搜索包含特定单词的所有推文
T.get('search/tweets', { q: 'banana since:2011-11-11', count: 100 }, function(err, data, response) {
console.log(data)
})
现在我需要解析收到的数据,但我有一些疑问。 你可以看到这张图片中的数据。
如何拆分每条推文并将它们加载到数组中?我还只需要关于推文的一些信息,例如 text 属性和用户的 name (我无法通过属性列表看到...有人可以告诉我为什么?)。
我尝试做的没有成功的就是在 this why 中访问 text 属性
tweets.statuses[0].metadata.text
【问题讨论】:
-
试试
tweets.statuses[0].text -
不错!它有效......但是[]中的元数据是什么?如何获取发表评论的用户名?
-
我不知道,你是怎么得到这个结果的。在 node-twitter 用户中 - {}。和
tweets.statuses[0].user.screen_name。尝试将console.log(data)更改为console.log(util.inspect(data, false, Infinity, true));
标签: javascript json node.js twitter