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 ...
随机推荐
- 设计模式学习一:strategyPattern
#ifndef STRATEGYPATTERN_H_#define STRATEGYPATTERN_H_#include<iostream>using namespace std; //策 ...
- AngularJs 基础(60分钟入门) (转)
AngularJs是一个不错的用于开发SPA应用(单页Web应用)的框架.单页Web应用(single page web application,SPA),就是只有一张Web页面的应用.浏览器一开始会 ...
- Memcached在.net中的应用
一.MemCached下载 服务端下载:http://memcachedproviders.codeplex.com/ client下载:path=/trunk">http://sou ...
- [POJ 3150] Cellular Automaton (矩阵高速幂 + 矩阵乘法优化)
Cellular Automaton Time Limit: 12000MS Memory Limit: 65536K Total Submissions: 3048 Accepted: 12 ...
- Java的wait(), notify()和notifyAll()使用心得(转)
本篇文章是对java的 wait(),notify(),notifyAll()进行了详细的分析介绍,需要的朋友参考下wait(),notify()和notifyAll()都是java.lang.Obj ...
- Follow your hear(跟着心走)
端午三天的哈尔滨之旅已经over,非常开心真的非常开心.听了刘四风老师的"为爱开讲.我爱这世界"的论坛,尽管.这三天老师讲的不多.可是句句是精华.Follow your heart ...
- How to import the www.googleapis.com SSL CA certification to the jks store file?
Assumed that you have installed JDK and configured JAVA_HOME for your current operation system. (1) ...
- libyuv编
下载代码(墙): git clone http://git.chromium.org/external/libyuv.git 用 make 编译(linux.mingw.cygwin): mak ...
- SQL注入问题
斌斌 (给我写信) 原创博文(http://blog.csdn.net/binbinxyz),转载请注明出处! 背景:对于ibaits参数引用可以使用#和$两种写法,其中#写法会采用预编译方式,将转义 ...
- MVC json
1. .net MVC中Controller 在mvc中所有的controller类都必须使用"Controller"后缀来命名 并且对Action也有一定的要求: 必须是一个pu ...