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, 交集,差集)的更多相关文章

  1. Python 分析Twitter用户喜爱的推文

    CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-5 @author: guaguastd @name: an ...

  2. Python 获取Facebook用户的Friends的爱好中的Top10

    CODE; #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-12 @author: guaguastd @name: f ...

  3. Python 获取Facebook用户Friends的爱好类别中的Top10

    CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-12 @author: guaguastd @name: f ...

  4. python 获取mysql数据库列表以及用户权限

    一.需求分析 需要统计出当前数据库的所有数据库名,以及每个用户的授权信息. 获取所有数据库 在mysql里面,使用命令: show databases 就可以获取所有数据库了 获取所有用户 执行命令: ...

  5. python flask获取微信用户信息报404,nginx问题

    在学习flask与微信公众号时问题,发现测试自动回复/wechat8008时正常,而测试获取微信用户信息/wechat8008/index时出现404.查询资料后收发是nginx配置问题. 在loca ...

  6. Redis & Python/Django 简单用户登陆

    一.Redis key相关操作: 1.del key [key..] 删除一个或多个key,如果不存在则忽略 2.keys pattern keys模式匹配,符合glob风格通配符,glob风格的通配 ...

  7. Zabbix中获取各用户告警媒介分钟级统计

    任务内容: 获取Zabbix各用户告警媒介分钟级统计,形成趋势图,便于观察各用户在每分钟收到的告警数量,在后续处理中,可以根据用户在某时间段内(例如3分钟内)收到的邮件总数,来判断是否有告警洪水的现象 ...

  8. 用 Python 获取 B 站播放历史记录

    用 Python 获取 B 站播放历史记录 最近 B 站出了一个年度报告,统计用户一年当中在 B 站上观看视频的总时长和总个数.过去一年我居然在 B 站上看了2600+个视频,总计251个小时,居然花 ...

  9. 渗透测试环境搭建以及使用sqlmap获取mysql用户数据库密码

    通过sqlmap检测sql注入漏洞 安装SQLmap漏洞查看工具 安装渗透测试演练系统DVWA 使用SQLmap进行sql注入并获得后台管理员adnim帐号和密码 环境介绍 安装SQLmap:Rich ...

随机推荐

  1. html5载入JS引用

    直接上代码 w文件 <?xml version="1.0" encoding="UTF-8"? > <div xmlns="http ...

  2. ASP.NET关于Login控件使用,LoginView 控件,CreateUserWizard 控件

    原文:ASP.NET关于Login控件使用,LoginView 控件,CreateUserWizard 控件 Login控件它是属于Membership服务的一部分,必须配置Membership提供程 ...

  3. 黄聪:Microsoft Enterprise Library 5.0 系列教程(七) Exception Handling Application Block

    原文:黄聪:Microsoft Enterprise Library 5.0 系列教程(七) Exception Handling Application Block 使用企业库异常处理应用程序模块的 ...

  4. Windows Phone开发(39):漫谈关键帧动画上篇

    原文:Windows Phone开发(39):漫谈关键帧动画上篇 尽管前面介绍的几种动画会让觉得很好玩了,但是,不知道你是否发现,在前面说到的一系列XXXAnimation中,都有一个共同点,那就是仅 ...

  5. python学习笔记之六:更加抽象

    Python被称为面向对象的语言,创建自己的对象是python非常核心的概念.这里会介绍如何创建对象,以及多态,封装,方法,特性,超类以及继承的概念. 一. 对象的魔力 面向对象程序设计中的术语 对象 ...

  6. 关于bind函数和connect函数的测试结论

    1. 一般客户端不用绑定,系统给你自动分配(有些ip不是固定的,bind也不是一个好方法):而服务器需要绑定,因为需要给客户端一个众所周知的固定的地址: 2. 关于bind错误,可以用WSAGetLa ...

  7. java获取指定地址图片高度宽度简单代码

    package com.test; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.In ...

  8. Xamarin 手动安装步骤+破解

    原文:Xamarin 手动安装步骤+破解 由于Xamarin运行的时候有很多依赖项,所以现在在官网上下载的XamarinInstall只是一个下载安装器,并不是软件包.它会自动下载安装所需的依赖软件, ...

  9. Access之C#连接Access

    原文:Access之C#连接Access 如果是个人用的小程序的话.一般都推荐用Sqlite和Access 使用SQlite数据库需要安装SQLite驱动,详情:SQLite之C#连接SQLite 同 ...

  10. Oracle SQL Lesson (4) - 使用转换函数和条件表达式

    隐式转换select * from emp where empno='7788'字符(char,varchar2)转换为数字(number)或日期(date)数字或日期转换为字符 显式转换字符转换为数 ...