首页 > 代码库 > Python 提取Twitter用户的Tweet
Python 提取Twitter用户的Tweet
CODE:
#!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-31 @author: guaguastd @name: harvest_user_tweet.py ''' if __name__ == '__main__': # import json import json # import search from search import search_for_tweet # import harvest_user_timeline from user import harvest_user_timeline # import login, see http://blog.csdn.net/guaguastd/article/details/31706155 from login import twitter_login # get the twitter access api twitter_api = twitter_login() # import twitter_text import twitter_text while 1: query = raw_input('\nInput the query (eg. #MentionSomeoneImportantForYou, exit to quit): ') if query == 'exit': print 'Successfully exit!' break statuses = search_for_tweet(twitter_api, query) ex = twitter_text.Extractor(statuses) screen_names = ex.extract_mentioned_screen_names_with_indices() screen_names = [screen_name['screen_name'] for screen_name in screen_names] for screen_name in screen_names: #print json.dumps(screen_names, indent=1) tweets = harvest_user_timeline(twitter_api, screen_name=screen_name, max_results=200) print json.dumps(tweets, indent=1)
RESULT:
"in_reply_to_status_id": null, "id": 492075239283884032, "favorite_count": 0, "source": "<a href=http://www.mamicode.com/"http://twitter.com/" rel=/"nofollow/">Twitter Web Client", >
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。