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的更多相关文章

  1. python之路:用户输入(一)

    python之路:用户输入(一) 好了,现在我学了点博客的用法,现在不会像以前的那么土了.好吧,不多说,我要讲课了. 今天,我会用情景实例给大家说这个用户输入. 情景是:你是IT教育的python带头 ...

  2. python爬虫之User-Agent用户信息

    python爬虫之User-Agent用户信息 爬虫是自动的爬取网站信息,实质上我们也只是一段代码,并不是真正的浏览器用户,加上User-Agent(用户代理,简称UA)信息,只是让我们伪装成一个浏览 ...

  3. Python 获取Twitter用户与Friends和Followers的关系(eg, 交集,差集)

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

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

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

  5. 使用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 ...

  6. Python 获取Google+特定用户最新动态

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

  7. Python 基础之二用户交互input

    Input是个内建函数: >>> input <built-in function input> >>>   具体用法:接收用户输入的内容,输入的字符串 ...

  8. Python 对Twitter中指定话题的被转载Tweet数量的频谱分析

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

  9. Python 收集Twitter时间序列数据

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

随机推荐

  1. LA3026 - Period(KMP)

    For each prefix of a given string S with N characters (each character has an ASCII code between 97 a ...

  2. SQL Server管理员专用连接的使用

    原文:SQL Server管理员专用连接的使用 作为一名DBA,经常会处理一些比较棘手的服务无响应问题,鉴于事态的严重性,多数DBA可能直接用“重启”大法,以便尽快的恢复生产环境的正常运转,但是多数情 ...

  3. poj1276--Cash Machine(多背包被判刑了)

    Cash Machine Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 27804   Accepted: 9915 Des ...

  4. MySQL 正則表達式搜索

    products表例如以下: 1. 基本字符匹配 使用正則表達式与LIKE的差别,正則表達式是在整个列搜索,仅仅要prod_name中包括了所搜索的字符就能够了,而LIKE假设不用通配符,那么要求pr ...

  5. 《Javascript权威指南》13号学习笔记:使用日期和时间

    一.创Date示例 1.Date类的方法和属性是非常不静,故,申请书Date属性和方法之前.必须创建Date类的实例. var date = new Date();  //以当前日期和时间创建实例. ...

  6. Mac OS温馨提示17:七彩花哨的输入

    OSX Mavericks中国的文字输入功能,色于windows,甚至提供了强大的手写输入功能和语音输入功能,而且发展到如今,已经有非常多种第三方输入法支持Mac了. 一.主要的输入法        ...

  7. hdu 4691 最长的共同前缀 后缀数组 +lcp+rmq

    http://acm.hdu.edu.cn/showproblem.php? pid=4691 去年夏天,更多的学校的种族称号.当时,没有后缀数组 今天将是,事实上,自己的后缀阵列组合rmq或到,但是 ...

  8. Nginx + IIS

    Nginx + IIS 配置,实现负载均衡   当你的Web应用程序访问量大的时候,一台服务器可能会因为压力过大而无法处理所有的请求.此时,可以增加服务器,采用负载均衡来分担所有的请求.关于Nginx ...

  9. zoj 3820 Building Fire Stations(树上乱搞)

    做同步赛的时候想偏了,状态总是时好时坏.这状态去区域赛果断得GG了. 题目大意:给一棵树.让求出树上两个点,使得别的点到两个点较近的点的距离最大值最小. 赛后用O(n)的算法搞了搞,事实上这道题不算难 ...

  10. 使用Heroku,需要locale至zh_CN,代替zh-CN

    使用Heroku.需要locale至zh_CN,代替zh-CN 我认为这是由于在application.rb于,config.i18n.default_locale默认接受值这是Symbol, 而当我 ...