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 ...
随机推荐
- Facebook新框架React Native,一套搞定App开发[转]
Facebook新框架React Native,一套搞定App开发 本文来自微信公众号“给产品经理讲技术”(pm_teacher),欢迎关注. 做为一名产品经理,你是否遇到过这样的窘境,“帮我把字体调 ...
- Lua 脚本语法说明(转)
Lua脚本语法说明(增加lua5.1部份特性) Lua 的语法比较简单,学习起来也比较省力,但功能却并不弱. 所以,我只简单的归纳一下Lua的一些语法规则,使用起来方便好查就可以了.估计看完了,就懂得 ...
- POJ3623:Best Cow Line, Gold(后缀数组)
Description FJ is about to take his N (1 ≤ N ≤ 30,000) cows to the annual"Farmer of the Year&qu ...
- 假设synthesize省略,语义属性声明assign retain copy时间,为了实现自己的setter和getter方法
假设synthesize省略,而且我们自己实现setter和getter方法时,系统就不会生成相应的setter和getter方法,还有实例变量 1,当把语义特性声明为assign时,setter和g ...
- Swift学习资料
http://www.hangge.com/blog/cache/category_72_1.html
- 香蕉派路由功Openwrt、Android功耗对照測试
路由这个东西是要长期通电使用的,所以功耗也是须要关注的.如今香蕉派路由已经有了openwrt和android两个 系统,这两个系统的功耗是否一样呢? 測试工具:QUIGG的德国产功耗測试仪一个.手机充 ...
- * 类描写叙述:字符串工具类 类名称:String_U
/****************************************** * 类描写叙述:字符串工具类 类名称:String_U * ************************** ...
- hdu 5077 NAND(暴力打表)
题目链接:hdu 5077 NAND 题目大意:Xiaoqiang要写一个编码程序,然后依据x1,x2,x3的值构造出8个字符.如今给定要求生成的8个字符.问 说Xiaoqiang最少要写多少行代码. ...
- yarn环境跑mapreduce报错某个container 600s未报告进度超时被杀
问题: 发现每次reduce阶段跑到98%,相关的container被杀.报出的log大概的意思:container 600s未报告进度超时被杀 解决的方法: 在mapreduce程序里加上 conf ...
- 本文摘录 - Infobright
背景 论文 Brighthouse: AnAnalytic Data Warehouse for Ad-hoc Queries.VLDB 2008 brighthouse它是一个面向列的数据仓库.在数 ...