码迷,mamicode.com
首页 > 编程语言 > 详细

Python 对Twitter中指定话题的被转载Tweet数量的频谱分析

时间:2014-07-10 23:29:30      阅读:311      评论:0      收藏:0      [点我收藏+]

标签:twitter   可视化   数据挖掘   

CODE:

#!/usr/bin/python 
# -*- coding: utf-8 -*-

'''
Created on 2014-7-10
@author: guaguastd
@name: retweet_frequency_map.py
'''

if __name__ == '__main__':
    
    # import visualize
    from visualize import visualize_frequency_map
    
    # pip install prettytable
    # from prettytable import PrettyTable

    # import search
    from search import search_for_tweet
      
    # 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 tweet
    from tweet import popular_retweets
    
    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)
        retweets = popular_retweets(statuses)
        counts = [count for count, _, _ in retweets]
        sTitle = "Retweets"
        xLabel = "Bins (number of times retweeted)"
        yLabel = "Number of tweets in bin"
        visualize_frequency_map(counts, sTitle, xLabel, yLabel)

RESULT:

Input the query (eg. #MentionSomeoneImportantForYou, exit to quit): #MentionSomeoneImportantForYou
Length of statuses 95

Input the query (eg. #MentionSomeoneImportantForYou, exit to quit): 

bubuko.com,布布扣

Python 对Twitter中指定话题的被转载Tweet数量的频谱分析,布布扣,bubuko.com

Python 对Twitter中指定话题的被转载Tweet数量的频谱分析

标签:twitter   可视化   数据挖掘   

原文地址:http://blog.csdn.net/guaguastd/article/details/37647881

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!