Python 获取Twitter用户与Friends和Followers的关系(eg, 交集,差集)
CODE:
#!/usr/bin/python
# -*- coding: utf-8 -*- '''
Created on 2014-7-30
@author: guaguastd
@name: friends_followers_analyzer.py
''' if __name__ == '__main__': # import json
#import json # import search
from search import search_for_tweet # import get_friends_followers_ids
from user import get_friends_followers_ids, setwise_friends_followers_analysis # 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)
friends_ids, followers_ids = get_friends_followers_ids(twitter_api,
screen_name=screen_name,
friends_limit=10,
followers_limit=10)
setwise_friends_followers_analysis(screen_name, friends_ids, followers_ids)
RESULT:
Input the query (eg. #MentionSomeoneImportantForYou, exit to quit): #MentionSomeoneImportantForYou
Length of statuses 30
Encountered 401 Error (Not Authorized)
Fetched 0 total friends ids for mcnasty_super
Encountered 401 Error (Not Authorized)
Fetched 0 total followers ids for mcnasty_super
mcnasty_super is following 0
mcnasty_super is being followed by 0
0 of 0 are not following mcnasty_super back
0 of 0 are not being followed back by mcnasty_super
mcnasty_super has 0 mutual friends
Fetched 5000 total friends ids for Justina25ita
Fetched 5000 total followers ids for Justina25ita
Justina25ita is following 10
Justina25ita is being followed by 10
6 of 10 are not following Justina25ita back
6 of 10 are not being followed back by Justina25ita
Justina25ita has 4 mutual friends
BadStatusLine encountered. Continuing.
Fetched 5000 total friends ids for CarolRibTorres
Fetched 5000 total followers ids for CarolRibTorres
CarolRibTorres is following 10
CarolRibTorres is being followed by 10
1 of 10 are not following CarolRibTorres back
1 of 10 are not being followed back by CarolRibTorres
CarolRibTorres has 9 mutual friends
Fetched 5000 total friends ids for CarolRibTorres
Fetched 5000 total followers ids for CarolRibTorres
CarolRibTorres is following 10
CarolRibTorres is being followed by 10
1 of 10 are not following CarolRibTorres back
1 of 10 are not being followed back by CarolRibTorres
CarolRibTorres has 9 mutual friends
Fetched 5000 total friends ids for JustinBieber
JustinBieber is following 10
JustinBieber is being followed by 10
10 of 10 are not following JustinBieber back
10 of 10 are not being followed back by JustinBieber
JustinBieber has 0 mutual friends
Fetched 5000 total followers ids for JustinBieber
Fetched 2818 total friends ids for Janoskians
Fetched 5000 total followers ids for Janoskians
Janoskians is following 10
Janoskians is being followed by 10
10 of 10 are not following Janoskians back
10 of 10 are not being followed back by Janoskians
Janoskians has 0 mutual friends
Fetched 5000 total friends ids for 5SOS
Fetched 5000 total followers ids for 5SOS
5SOS is following 10
5SOS is being followed by 10
10 of 10 are not following 5SOS back
10 of 10 are not being followed back by 5SOS
5SOS has 0 mutual friends
Fetched 63 total friends ids for shots
Fetched 5000 total followers ids for shots
shots is following 10
shots is being followed by 10
10 of 10 are not following shots back
10 of 10 are not being followed back by shots
shots has 0 mutual friends
Fetched 5000 total friends ids for CarolRibTorres
Fetched 5000 total followers ids for CarolRibTorres
CarolRibTorres is following 10
CarolRibTorres is being followed by 10
1 of 10 are not following CarolRibTorres back
1 of 10 are not being followed back by CarolRibTorres
CarolRibTorres has 9 mutual friends
Fetched 5000 total friends ids for JustinBieber
Fetched 5000 total followers ids for JustinBieber
JustinBieber is following 10
JustinBieber is being followed by 10
10 of 10 are not following JustinBieber back
10 of 10 are not being followed back by JustinBieber
JustinBieber has 0 mutual friends
Fetched 2818 total friends ids for Janoskians
Fetched 5000 total followers ids for Janoskians
Janoskians is following 10
Janoskians is being followed by 10
10 of 10 are not following Janoskians back
10 of 10 are not being followed back by Janoskians
Janoskians has 0 mutual friends
Python 获取Twitter用户与Friends和Followers的关系(eg, 交集,差集)的更多相关文章
- Python 分析Twitter用户喜爱的推文
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-5 @author: guaguastd @name: an ...
- Python 获取Facebook用户的Friends的爱好中的Top10
CODE; #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-12 @author: guaguastd @name: f ...
- Python 获取Facebook用户Friends的爱好类别中的Top10
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-12 @author: guaguastd @name: f ...
- python 获取mysql数据库列表以及用户权限
一.需求分析 需要统计出当前数据库的所有数据库名,以及每个用户的授权信息. 获取所有数据库 在mysql里面,使用命令: show databases 就可以获取所有数据库了 获取所有用户 执行命令: ...
- python flask获取微信用户信息报404,nginx问题
在学习flask与微信公众号时问题,发现测试自动回复/wechat8008时正常,而测试获取微信用户信息/wechat8008/index时出现404.查询资料后收发是nginx配置问题. 在loca ...
- Redis & Python/Django 简单用户登陆
一.Redis key相关操作: 1.del key [key..] 删除一个或多个key,如果不存在则忽略 2.keys pattern keys模式匹配,符合glob风格通配符,glob风格的通配 ...
- Zabbix中获取各用户告警媒介分钟级统计
任务内容: 获取Zabbix各用户告警媒介分钟级统计,形成趋势图,便于观察各用户在每分钟收到的告警数量,在后续处理中,可以根据用户在某时间段内(例如3分钟内)收到的邮件总数,来判断是否有告警洪水的现象 ...
- 用 Python 获取 B 站播放历史记录
用 Python 获取 B 站播放历史记录 最近 B 站出了一个年度报告,统计用户一年当中在 B 站上观看视频的总时长和总个数.过去一年我居然在 B 站上看了2600+个视频,总计251个小时,居然花 ...
- 渗透测试环境搭建以及使用sqlmap获取mysql用户数据库密码
通过sqlmap检测sql注入漏洞 安装SQLmap漏洞查看工具 安装渗透测试演练系统DVWA 使用SQLmap进行sql注入并获得后台管理员adnim帐号和密码 环境介绍 安装SQLmap:Rich ...
随机推荐
- 安装pygame
pygame的安装 我们首先要去到:http://www.pygame.org/download.shtml 下载我们所需要的软件包: 我选择的是:pygame-1.9.2a0.win32-py3.2 ...
- Java 序列化Serializable详解(附详细例子)
Java 序列化Serializable详解(附详细例子) 1.什么是序列化和反序列化 Serialization(序列化)是一种将对象以一连串的字节描述的过程:反序列化deserialization ...
- 故障排查:是什么 导致了服务器端口telnet失败?(转)
telnet命令的主要作用是与目标端口进行TCP连接(即完成TCP三次握手).当服务端启动后,但是telnet其监听的端口,却失败了.或者,当服务端运行了一段时间后,突然其监听的端口telnet不通了 ...
- CSS+DIV+HTML(一)--HTML总结
一.定义 HTML(Hyper Text Markup Language),标记语言. 二.主要内容: HTML元素分为三类:块级标签.内联标签.可变标签.差别在于: 块级元素:在默认情况下会换行显示 ...
- SharePoint综合Excel数据与Excel Web Access Web部分
SharePoint综合Excel数据与Excel Web Access Web部分 Excel Web Access Web零件SharePoint于Excel以电子形式提交数据. 1. 打开Exc ...
- Windows Server 2012 R2在桌面上显示计算机/网络图标
原文 Windows Server 2012 R2在桌面上显示计算机/网络图标 从Windows2012开始,微软取消了服务器桌面个性化选项,如何重新调出配置界面,可以使用微软命令调出.具体方法如下: ...
- 玩转html5(四)----使用canvas画一个时钟(可以动的哦!)
先给个效果图,我画的比较丑,大家可以自己美化一下, 直接上代码: <!DOCTYPE html> <meta charset="utf-8"> <ht ...
- 升级到cocos2d-x 2.0.2代码差异
来自:http://www.cnblogs.com/TopWin/archive/2012/09/12/2682042.html 近期看cocos2d-x 2.0.2公布后升级了一下.升级后发现又出现 ...
- 高性能 Socket 组件 HP-Socket v3.2.1-RC2 公布
HP-Socket 是一套通用的高性能 TCP/UDP Socket 组件,包括服务端组件.client组件和 Agent 组件,广泛适用于各种不同应用场景的 TCP/UDP 通信系统,提供 C/C+ ...
- 我理解设计模式C++实现观察者模式Observer Pattern
概述: 近期中国股市起起伏伏,当然了起伏就用商机,小明发现商机后果断想入市,买入了中国证券,他想在电脑client上,网页上,手机上,iPad上都能够查看到该证券的实时行情,这样的情况下我们应该怎么设 ...