Python 分析Twitter用户喜爱的推文
CODE:
#!/usr/bin/python
# -*- coding: utf-8 -*- '''
Created on 2014-8-5
@author: guaguastd
@name: analyze_favorite_tweet.py
''' if __name__ == '__main__': # import json
#import json # import search
from search import search_for_tweet # import get_friends_followers_ids
from user import crawl_followers # import login, see http://blog.csdn.net/guaguastd/article/details/31706155
from login import twitter_login # import tweet
from tweet import analyze_favorites_tweet # 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)
analyze_favorites_tweet(twitter_api, screen_name)
RESULT:
Input the query (eg. #MentionSomeoneImportantForYou, exit to quit): Core Python
Length of statuses 59
Number of favorites: 200 Common entities in favorites...
+--------+------------------------+
| Entity | Count |
+--------+------------------------+
| 72 | the |
| 72 | to |
| 57 | a |
| 56 | of |
| 53 | in |
| 44 | on |
| 37 | is |
| 36 | for |
| 34 | and |
| 29 | I |
| 28 | you |
| 24 | my |
| 21 | - |
| 21 | at |
| 19 | with |
| 17 | be |
| 17 | by |
| 15 | talk |
| 15 | are |
| 15 | from |
| 14 | The |
| 14 | this |
| 13 | can |
| 13 | that |
| 13 | snim2 |
| 12 | @snim2 |
| 12 | an |
| 11 | Python |
| 11 | your |
| 11 | about |
| 10 | it |
| 10 | was |
| 10 | all |
| 10 | ep14 |
| 9 | europython |
| 9 | now |
| 9 | or |
| 8 | via |
| 7 | A |
| 7 | Here |
| 7 | if |
| 7 | not |
| 7 | our |
| 7 | have |
| 7 | who |
| 7 | #ep14 |
| 7 | as |
| 6 | new |
| 6 | me |
| 6 | just |
| 6 | #europython |
| 6 | slides |
| 6 | & |
| 5 | concurrency |
| 5 | My |
| 5 | IPython |
| 5 | so |
| 5 | more |
| 5 | paper |
| 5 | also |
| 5 | most |
| 5 | see |
| 5 | available |
| 5 | video |
| 5 | write |
| 5 | out |
| 5 | piece |
| 5 | software |
| 4 | has |
| 4 | when |
| 4 | :) |
| 4 | Research |
| 4 | here: |
| 4 | take |
| 4 | If |
| 4 | being |
| 4 | code |
| 4 | what |
| 4 | help |
| 4 | really |
| 4 | For |
| 4 | some |
| 4 | up |
| 4 | python |
| 4 | This |
| 4 | based |
| 4 | will |
| 4 | You |
| 4 | he |
| 3 | Haskell |
| 3 | @europython |
| 3 | much |
| 3 | photo |
| 3 | #python |
| 3 | easy |
| 3 | post |
| 3 | own |
| 3 | #LGBT |
| 3 | papers |
| 3 | time |
| 3 | Our |
| 3 | Why |
| 3 | answer |
| 3 | first |
| 3 | one |
| 3 | open |
| 3 | than |
| 3 | ep2014 |
| 3 | get |
| 3 | LGBT |
| 3 | Gaza |
| 3 | read |
| 3 | Slides |
| 3 | presentation |
| 3 | large |
| 3 | learned |
| 3 | learn |
| 3 | don't |
| 3 | good |
| 3 | did |
| 3 | Thanks |
| 3 | like |
| 3 | tweets/second |
| 3 | his |
| 3 | wrote |
| 3 | please |
| 3 | Software |
| 3 | analysis |
| 3 | Here's |
| 3 | .. |
| 3 | An |
| 3 | great |
| 3 | use |
| 3 | | |
| 3 | EuroPython |
| 3 | you're |
| 3 | their |
| 3 | but |
| 3 | why |
| 3 | should |
| 3 | means |
| 3 | #ep2014 |
| 3 | keynote |
| 3 | day |
| 3 | know |
| 3 | because |
| 3 | Great |
| 2 | under |
| 2 | Amazon |
| 2 | Church |
| 2 | Group |
| 2 | aware |
| 2 | must |
| 2 | want |
| 2 | how |
| 2 | interview |
| 2 | after |
| 2 | things |
| 2 | feedback |
| 2 | over |
| 2 | them |
| 2 | Check |
| 2 | Shakira |
| 2 | got |
| 2 | messages |
| 2 | days |
| 2 | Please |
| 2 | Notebook |
| 2 | @parallellaboard |
| 2 | “Can |
| 2 | mine |
| 2 | Twisted |
| 2 | do |
| 2 | #concurrency |
| 2 | officially |
| 2 | w/ |
| 2 | John |
| 2 | said |
| 2 | never |
| 2 | I've |
| 2 | been |
| 2 | twistedmatrix |
| 2 | make |
| 2 | jobs. |
| 2 | #EuroPython |
| 2 | Use |
| 2 | way |
| 2 | role |
| 2 | test |
| 2 | update |
| 2 | parallellaboard |
| 2 | daily |
| 2 | Just |
| 2 | MT |
| 2 | MP |
| 2 | It's |
| 2 | following |
| 2 | may |
| 2 | Model |
| 2 | switch |
| 2 | RT |
| 2 | tweets |
| 2 | WeAreN |
| 2 | name |
| 2 | attended |
| 2 | programming |
| 2 | think |
| 2 | message |
| 2 | short |
| 2 | Do |
| 2 | online |
| 2 | science, |
| 2 | #WeAreN |
| 2 | going |
| 2 | Growth |
| 2 | where |
| 2 | #synod |
| 2 | 3 |
| 2 | jobs |
| 2 | many |
| 2 | Jeremy |
| 2 | those |
| 2 | these |
| 2 | engineering |
| 2 | GNU |
| 2 | different |
| 2 | surveillance |
| 2 | week |
| 2 | blog |
| 2 | LindaWoodhead |
| 2 | start |
| 2 | ن |
| 2 | How |
| 2 | watched |
| 2 | trash |
| 2 | #Python |
| 2 | coverage |
| 2 | @LindaWoodhead |
| 2 | remote |
| 2 | consider |
| 2 | program |
| 2 | very |
| 2 | St |
| 2 | Your |
| 2 | github |
| 2 | that's |
| 2 | its |
| 2 | it. |
| 2 | it: |
| 2 | c_of_e |
| 2 | research |
| 2 | together |
| 2 | without |
| 2 | nothing |
| 2 | pre-print |
| 2 | during |
| 2 | Part |
| 2 | last |
| 2 | Steve |
| 2 | point |
| 2 | church |
| 2 | Women |
| 2 | error |
| 2 | arXiv |
| 2 | http://t.co/0yBSWrVaUW |
| 2 | person |
| 2 | Names |
| 2 | docker |
| 2 | Reproducible |
| 2 | source |
| 2 | popular |
| 2 | back |
| 2 | @twistedmatrix |
| 2 | am |
| 2 | < |
| 2 | @PyConUK |
| 2 | AV |
| 2 | Implement |
| 2 | asyncio |
| 2 | Git |
| 2 | try |
| 2 | making |
| 2 | involved |
| 2 | Algorithm?”: |
| 2 | tools |
| 2 | … |
| 2 | Video |
| 2 | links |
| 2 | profile |
| 2 | lines |
| 2 | One |
| 2 | 2015 |
| 2 | Can |
| 2 | lecture |
| 2 | data |
| 2 | need |
| 2 | which |
| 2 | Some |
| 2 | Bishop |
| 2 | fact |
| 2 | local |
| 2 | computer |
| 2 | Good |
| 2 | synod |
| 2 | passing |
| 2 | it's |
| 2 | PyConUK |
| 2 | #asyncio |
| 2 | intro |
| 2 | Oxford |
| 2 | single |
| 2 | latest |
| 2 | CofE |
| 2 | async |
| 2 | Telegraph |
| 2 | growth |
| 2 | Science |
| 2 | problem |
| 2 | this: |
+--------+------------------------+ Some statistics about the content of the favorities... Lexical diversity (words): 0.605255023184
Lexical diversity (screen names): 1.0
Lexical diversity (hashtags): 0.831932773109
Averge words per tweet: 16.175
Number of favorites: 2 Common entities in favorites...
+--------+-------------+
| Entity | Count |
+--------+-------------+
| 2 | @AndersInno |
| 2 | AndersInno |
+--------+-------------+ Some statistics about the content of the favorities... Lexical diversity (words): 0.9375
Lexical diversity (screen names): 1.0
Lexical diversity (hashtags): 0.75
Averge words per tweet: 8.0
Number of favorites: 6 Common entities in favorites...
+--------+-------+
| Entity | Count |
+--------+-------+
| 4 | the |
| 3 | to |
| 2 | be |
| 2 | of |
| 2 | this |
| 2 | is |
| 2 | in |
| 2 | I |
| 2 | a |
+--------+-------+ Some statistics about the content of the favorities... Lexical diversity (words): 0.872340425532
Lexical diversity (screen names): 1.0
Lexical diversity (hashtags): 1.0
Averge words per tweet: 15.6666666667
Number of favorites: 0 Common entities in favorites...
+--------+-------+
| Entity | Count |
+--------+-------+
+--------+-------+ Some statistics about the content of the favorities... No statuses to analyze
Python 分析Twitter用户喜爱的推文的更多相关文章
- Python 获取Twitter用户与Friends和Followers的关系(eg, 交集,差集)
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-30 @author: guaguastd @name: f ...
- 在Twitter信息流中大规模应用深度学习——推文的相关度计算使用了深度学习
我们如何对信息流进行排序? 在引入排序算法之前,信息流的组成非常简单:收集所有由你的关注对象在你最后一次登录Twitter之后发送的推文,再将它们按照时间倒序显示出来.这个看起来很简单,但要为数以亿计 ...
- 【Python数据分析】用户通话行为分析
主要工作: 1.对从网上营业厅拿到的用户数据.xls文件,通过Python的xlrd进行解析,计算用户的主叫被叫次数,通话时间,通话时段. 2.使用matplotlib画图包,将分析的结果直观的绘制出 ...
- Python分析44130条用户观影数据,挖掘用户与电影之间的隐藏信息!
01.前言 很多电影也上映,看电影前很多人都喜欢去 『豆瓣』 看影评,所以我爬取44130条 『豆瓣』 的用户观影数据,分析用户之间的关系,电影之间的联系,以及用户和电影之间的隐藏关系. 02.爬取观 ...
- [原创博文] 用Python做统计分析 (Scipy.stats的文档)
[转自] 用Python做统计分析 (Scipy.stats的文档) 对scipy.stats的详细介绍: 这个文档说了以下内容,对python如何做统计分析感兴趣的人可以看看,毕竟Python的库也 ...
- 推文《阿里凑单算法首次公开!基于Graph Embedding的打包购商品挖掘系统解析》笔记
推文<阿里凑单算法首次公开!基于Graph Embedding的打包购商品挖掘系统解析>笔记 从17年5月份开始接触Graph Embedding,学术论文读了很多,但是一直不清楚这技术是 ...
- 用Python分析国庆旅游景点,告诉你哪些地方好玩、便宜、人又少
注:本人参考“裸睡的猪”公众号同名文章,学习使用. 一.目标 使用Python分析出国庆哪些旅游景点:好玩.便宜.人还少的地方,不然拍照都要抢着拍! 二.获取数据 爬取出行网站的旅游景点售票数据,反映 ...
- 五月天的线上演唱会你看了吗?用Python分析网友对这场线上演唱会的看法
前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者:CDA数据分析师 豆瓣9.4分!这场线上演唱会到底多好看? 首先让我 ...
- 完成分析 FastAdmin 用户余额功能(后台篇)
分析 FastAdmin 用户余额功能(后台篇) 分析 FastAdmin 用户余额功能(后台篇) 虽然 FastAdmin 主要针对后台的框架,但也在不断完善前台的功能,有一天小伙伴在社区里提了一个 ...
随机推荐
- c++, class的大小
不为类.对象的函数分配空间: 在类中如果有virtual声明的虚函数,则会隐藏一个指针,该指针指向虚函数表,这对于纯虚函数也是一样: 对于虚继承,还有一个指向父类的指针,该指针为指向虚基类的指针(Po ...
- 大白痴学习webmagic
摘要 webmagic 学习 从头 刚刚开始学,很多东西可能理解错了,还请各位指教 一些基本类: Request:包含要爬行的url和一些附加信息,是Page的一个成员变量 主要成员变量 String ...
- 用js模拟struts2的多action调用
近期修了几个struts2.1升级到2.3后动态方法调用失效的bug,深有感悟, 原始方法能够參考我之前的博文:struts2.1升级到2.3后动态调用方法问题 可是我那种原始方法有一个局限,就是在s ...
- Swift - 使用位运算提取颜色,合并颜色
通常我们可以使用16进制的格式表示RGB颜色,比如0x2f88c0.通过位操作运算,能很方便的将其中的R,G,B颜色各部分分别提取出来.反之,也可以将R,G,B颜色值组合成一个完整的颜色. 1,提取颜 ...
- MSSQL - 多表查询
SELECT u.UserNumber, u.UserName, c.CarNumber, c.CarName, c.CarEngine, s.BuyLs, s.BuyTime FROM Tb_Sal ...
- 开源JDBC工具类DbUtils
本篇将会详细地介绍Apache公司的JDBC帮助工具类DbUtils以及如何使用.在上一篇中我们已经通过将以前对dao层使用JDBC操作数据库的冗余代码进行了简易封装形成自己的简单工具类JdbcUti ...
- 细节!重点!易错点!--面试java基础篇(二)
今天来给大家分享一下java的重点易错点第二部分,也是各位同学面试需要准备的,欢迎大家交流指正. 1.字符串创建与存储机制:当创建一个字符串时,首先会在常量池中查找是否已经有相同的字符串被定义,其判断 ...
- 安装m2eclipse
Help->Eclipse Marketplace- 搜索 maven 安装 Maven Integration for Eclipse
- 九度OnlineJudge之1018:统计同成绩学生人数
题目描述: 读入N名学生的成绩,将获得某一给定分数的学生人数输出. 输入: 测试输入包含若干测试用例,每个测试用例的格式为 第1行:N 第2行:N名学生的 ...
- const限定符的作用
const限定符的作用: 1.定义const常量:const可以将一个对象变成一个常量,不可被修改,所以定义的 时候必须进行初始 ...