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


    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('
    Input 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): 


  • 相关阅读:
    sqlserver查询某个数据库有多少个表 ,存过,函数,视图
    C# 金额转为大写金额
    C# TextBox中只能输入数字的几种常用方法(C#)
    C# 设置Excel单元格属性
    MS SQL 维护小记
    webapi demo
    远程 TeamViewer
    https://github.com/
    C# Fun 类似委托
    技术点文章收集
  • 原文地址:https://www.cnblogs.com/blfshiye/p/5104595.html
Copyright © 2020-2023  润新知