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. Winform WebBrowser引用IE版本问题

    做了一个Winform的项目.项目里使用了WebBrowser控件.以前一直都以为WebBrowser是直接调用的系统自带的IE,IE是呈现出什么样的页面WebBrowser就呈现出什么样的页面.其实 ...

  2. 【JAVA】【NIO】3、Java NIO Channel

    Java NIO和流量相似,但有些差异: ·通道可读写,流仅支持单向.读或写 ·异步通道读取 ·通道读写器,他们是和Buffer交替 道的实现 下面是Java NIO中最重要的通道的实现: ·File ...

  3. 【Android基础】listview控件的使用(2)-------继承自ListActivity的普通listview

    由于listview在android控件中的重要性,所以android为我们直接封装了一个类ListviewActivity,直接将listview封装在了activity之中,在本篇中,我将介绍在L ...

  4. 解决UnicodeEncodeError: 'ascii' codec can't encode characters in position 问题(转)

    UnicodeEncodeError: 'ascii' codec can't encode characters in position 8-11: ordinal not in range(128 ...

  5. Struts2之—实现自己的结果集的定义ajax

    项目中我们常常遇到这种需求--页面部分刷新.比如:加入用户,转到加入用户页面时,页面自己主动载入了全部部门. 完整流程:选择所属部门,填写username和password,点击"注冊&qu ...

  6. Javascript J更深层次的理解avascript 基础知识

    eval全局函数 dojo loader会看到如下的功能    var eval_ = new Function('return eval(arguments[0]);'); //Function 函 ...

  7. JavaScript之三:jQuery插件开发(一)

    在早期的开发中,正如前面闭包中所提到的那样,人们一开始并没有意识到要开发出插件这么个玩意儿,都是遇到啥写啥.在长期的工作中,人们发现很多代码是重复的,写了一遍又一遍,以登录页面为例,每写一次都需要重新 ...

  8. Computer Science 学习第四章--CPU 指令集和指令处理

    Instruction set Y86 指令集 运算符:addl, subl, andl, and xorl 跳转符:jmp,jle,jl,je,jne,jge, andjg 条件符:cmovle, ...

  9. error LNK2019: 解析的外部符号 __imp__DispatchMessageW@4,在函数的符号 _WinMain@16 据引述

    错误: 1>WinMain.obj : error LNK2019: 解析的外部符号 __imp__DispatchMessageW@4,在函数的符号 _WinMain@16 据引述 1> ...

  10. PHP上传文件(学习)

    <?php if(isset($_FILES['upfile'])) { if (is_uploaded_file($_FILES['upfile']['tmp_name'])){ $upfil ...