Python 得到Twitter所有用户friends和followers
CODE:
#!/usr/bin/python
# -*- coding: utf-8 -*- '''
Created on 2014-7-29
@author: guaguastd
@name: friends_followers_fetch.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 # 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)
print json.dumps(friends_ids, indent=1)
print json.dumps(followers_ids, indent=1)
RESULT:
Input the query (eg. #MentionSomeoneImportantForYou, exit to quit): #MentionSomeoneImportantForYou
Length of statuses 36
Fetched 1998 total friends ids for KaJoe243
Fetched 1055 total followers ids for KaJoe243
[
1422600199,
458688949,
1161253873,
1169815322,
776404981,
1592054046,
747340094,
631001110,
333957305,
770281080
]
[
244565875,
804283975,
529456713,
2482515389,
833212254,
2723007131,
2601424506,
823550654,
2591080621,
2719436949
]
Fetched 277 total friends ids for Boninajenny
Fetched 157 total followers ids for Boninajenny
[
2159357795,
213748275,
262804580,
820250366,
1713397874,
559150316,
972223820,
500760841,
598357813,
752105156
]
[
841258999,
2721645597,
636955955,
339051763,
319816176,
559150316,
820250366,
1524500682,
2657351222,
702425326
]
Fetched 1998 total friends ids for KaJoe243
Fetched 1055 total followers ids for KaJoe243
[
1422600199,
458688949,
1161253873,
1169815322,
776404981,
1592054046,
747340094,
631001110,
333957305,
770281080
]
[
244565875,
804283975,
529456713,
2482515389,
833212254,
2723007131,
2601424506,
823550654,
2591080621,
2719436949
]
Fetched 277 total friends ids for Boninajenny
Fetched 157 total followers ids for Boninajenny
[
2159357795,
213748275,
262804580,
820250366,
1713397874,
559150316,
972223820,
500760841,
598357813,
752105156
]
[
841258999,
2721645597,
636955955,
339051763,
319816176,
559150316,
820250366,
1524500682,
2657351222,
702425326
]
Fetched 277 total friends ids for Boninajenny
Fetched 157 total followers ids for Boninajenny
[
2159357795,
213748275,
262804580,
820250366,
1713397874,
559150316,
972223820,
500760841,
598357813,
752105156
]
[
841258999,
2721645597,
636955955,
339051763,
319816176,
559150316,
820250366,
1524500682,
2657351222,
702425326
]
Fetched 277 total friends ids for Boninajenny
Fetched 157 total followers ids for Boninajenny
[
2159357795,
213748275,
262804580,
820250366,
1713397874,
559150316,
972223820,
500760841,
598357813,
752105156
]
[
841258999,
2721645597,
636955955,
339051763,
319816176,
559150316,
820250366,
1524500682,
2657351222,
702425326
]
Fetched 359 total friends ids for SrhGV
BadStatusLine encountered. Continuing.
[
1175105167,
777552968,
560252027,
2524468307,
2649629004,
261332366,
2601711740,
1941138769,
407189800,
2554569862
]
[
1175105167,
1375314614,
1541598176,
1223010188,
2713154950,
1189139196,
1541577548,
1541607992,
440873116,
2439750032
]
Fetched 238 total followers ids for SrhGV
Fetched 196 total friends ids for PaulaAV2
Fetched 248 total followers ids for PaulaAV2
[
188478643,
840767317,
2540664564,
1176337274,
2192464466,
531881654,
492399548,
2596888296,
228811123,
357133822
]
[
2174949662,
374750493,
267452652,
863777972,
1511594922,
1255483015,
2528828622,
840767317,
437918534,
2596888296
]
Python 得到Twitter所有用户friends和followers的更多相关文章
- python之路:用户输入(一)
python之路:用户输入(一) 好了,现在我学了点博客的用法,现在不会像以前的那么土了.好吧,不多说,我要讲课了. 今天,我会用情景实例给大家说这个用户输入. 情景是:你是IT教育的python带头 ...
- python爬虫之User-Agent用户信息
python爬虫之User-Agent用户信息 爬虫是自动的爬取网站信息,实质上我们也只是一段代码,并不是真正的浏览器用户,加上User-Agent(用户代理,简称UA)信息,只是让我们伪装成一个浏览 ...
- Python 获取Twitter用户与Friends和Followers的关系(eg, 交集,差集)
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-30 @author: guaguastd @name: f ...
- Python 分析Twitter用户喜爱的推文
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-5 @author: guaguastd @name: an ...
- 使用Python对Twitter进行数据挖掘(Mining Twitter Data with Python)
目录 1.Collecting data 1.1 Register Your App 1.2 Accessing the Data 1.3 Streaming 2.Text Pre-processin ...
- Python 获取Google+特定用户最新动态
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-28 @author: guaguastd @name: l ...
- Python 基础之二用户交互input
Input是个内建函数: >>> input <built-in function input> >>> 具体用法:接收用户输入的内容,输入的字符串 ...
- Python 对Twitter中指定话题的被转载Tweet数量的频谱分析
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-10 @author: guaguastd @name: r ...
- Python 收集Twitter时间序列数据
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-18 @author: guaguastd @name: c ...
随机推荐
- 深入理解Javascript闭包概念
一.变量的作用域 要理解闭包,首先必须理解Javascript特殊的变量作用域. 变量的作用域无非就是两种:全局变量和局部变量. Javascript语言的特殊之处,就在于函数内部能够直接读取全局变量 ...
- ASP.NET自定义控件组件开发 第一章 待续
原文:ASP.NET自定义控件组件开发 第一章 待续 第一章:从一个简单的控件谈起 系列文章链接: ASP.NET自定义控件组件开发 第一章 待续 ASP.NET自定义控件组件开发 第一章 第二篇 接 ...
- Android源代码学习之六——ActivityManager框架解析
ActivityManager在操作系统中有关键的数据,本文利用操作系统源代码,逐步理清ActivityManager的框架,并从静态类结构图和动态序列图两个角度分别进行剖析,从而帮助开发者加强对系统 ...
- 【Android基础】AndroidManifest常用权限permission整理
android.permission.ACCESS_COARSE_LOCATION 通过WiFi或移动基站的方式获取用户错略的经纬度信息,定位精度大概误差在30~1500米 android.permi ...
- Android4.2.2由于越来越多的物理按键(frameworks)
当我们改变frameworks之后可能: make: *** [out/target/common/obj/PACKAGING/checkapi-current-timestamp] 错误 38 解决 ...
- S性能 Sigmoid Function or Logistic Function
S性能 Sigmoid Function or Logistic Function octave码 x = -10:0.1:10; y = zeros(length(x), 1); for i = 1 ...
- 大约cocos2d-X 3.x使用引擎版本自带的物理引擎Physics
今天打算用BOX2D物理引擎, 我想我以前听说过一些时间cocos2d-X在3.0版本封装自己的物理引擎Physics, 听名字很霸气量, 这的确是一个比BOX2D非常多( 毕竟是基于BOX2D封装的 ...
- JavaIO流程--创建文件和目录的实例
*创建函数: *public boolean createNewFile():创建文件 本文假设存在.不创造(转让file.createNewFile()返回false) *public bool ...
- 《学习opencv》笔记——矩阵和图像处理——cvMax,cvMaxS,cvMerge,cvMin and cvMinS
矩阵和图像操作 (1)cvMax函数 其结构 void cvMax(//比較两个图像取最大值 const CvArr* src1,//图像1 const CvArr* src2,//图像2 CvArr ...
- 于Eclipse传导C/C++配置方法开发(20140721新)
Eclipse 它是一个开源.基于Java可扩展的开发平台. 在其自己的.它只是一个框架和一组服务.对于通过插件组件构建开发环境. --从百度百科的短语. 简单的说Eclipse 是免费的开源的Jav ...