使用twit模块解析数据

时间:2014-11-23 21:04:48

标签: json node.js

我试图仅解析来自此代码的数据的文本:

// Our Twitter library
var Twit = require('twit');

// We need to include our configuration file
var T = new Twit(require('./config.js'));

T.get('search/tweets', { q: 'banana since:2011-11-11', count: 1 }, function(err, data, response) {
  console.log(data);
})

我尝试了data.text,但它返回的文字未定义。有帮助吗?谢谢。

data的输出:

{ statuses:
   [ { metadata: [Object],
       created_at: 'Sun Nov 23 21:03:40 +0000 2014',
       id: 536626155718070300,
       id_str: '536626155718070272',
       text: 'I actually ate a small piece of banana cake... @matthazard204 you\
'd be proud. But I still think they\'re gross',
       source: '<a href="http://twitter.com/download/android" rel="nofollow">Twi
tter for Android</a>',
       truncated: false,
       in_reply_to_status_id: null,
       in_reply_to_status_id_str: null,
       in_reply_to_user_id: null,
       in_reply_to_user_id_str: null,
       in_reply_to_screen_name: null,
       user: [Object],
       geo: null,
       coordinates: null,
       place: null,
       contributors: null,
       retweet_count: 0,
       favorite_count: 0,
       entities: [Object],
       favorited: false,
       retweeted: false,
       lang: 'en' } ],
  search_metadata:
   { completed_in: 0.011,
     max_id: 536626155718070300,
     max_id_str: '536626155718070272',
     next_results: '?max_id=536626155718070271&q=banana%20since%3A2011-11-11&cou
nt=1&include_entities=1',
     query: 'banana+since%3A2011-11-11',
     refresh_url: '?since_id=536626155718070272&q=banana%20since%3A2011-11-11&in
clude_entities=1',
     count: 1,
     since_id: 0,
     since_id_str: '0' } }

0 个答案:

没有答案