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 ...
随机推荐
- ebay的api开发技术说明,有点乱
使用eBay API的基本步骤引入 开始eBay API,例如,以下基本步骤需要: 1. 注册开发者账号: https://developer.ebay.com/join/Default.asp ...
- Mean Shift简介
Mean Shift,我们 翻译“平均漂移”. 其集群,图像平滑. 图像分割和跟踪已广泛应用.因为我现在认为追踪,因此推出Mean Shift该方法用于目标跟踪.从而MeanShift較全面的介绍. ...
- NTVS:把Visual Studio变成Node.js IDE 的工具
NTVS(Node.js Tools for Visual Studio) 运行于VS2012或者VS2013.一些node.js的爱好者已经从PTVS(Python Tools for Visual ...
- C#的WebBrowser控制浏览
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- JavaFX横幅类游戏开发 教训 游戏贴图
上一节课,我们即将完成战旗Demo有了一个大概的了解.教训这,我们将学习绘制游戏地图. 由于JavaFX 2.2中添加了Canvas相关的功能,我们就能够使用Canvas来实现游戏绘制了. 游戏地图绘 ...
- DevExpress 12.1 换肤 超级简单的方法(2013-11-5版)
本例子是按照DevExpress 12.1 版本 进行演示.请先准备好DevExpress.BonusSkins.v12.1.dll 和DevExpress.Utils.v12.1.dll 1.首先添 ...
- Android 4.4环境搭建——Android SDK下载与安装
学习开发Android应用程序,须要下载安装Android SDK.在Android的官方站点的二级域名http://developer.android.com/index.html中.能够下载到完整 ...
- SqlServer中存储过程中将Exec的执行结果赋值给变量输出
原文 SqlServer中存储过程中将Exec的执行结果赋值给变量输出 背景: 遇到这样一种情况:动态向存储过程中传入表名和表的某些属性(这里用到的是主键ID),然后利用这两个变量查出一条数据的某些字 ...
- S2SH新手框架结构的准备工作只需要导入这些文件
实习北京最近一直在某公司.时间很冲突,总想着有事找东西坐,思想,做事先成套我吧 一套完整的东西想好主题,术去实现了,在学校尽管说是学了J2EE,可是确实没学到东西,Struts2+Hibernate不 ...
- MEMO:UIButton 中的图片和标题 左对齐
UIButton setImage 和 setTitle之后.默认 image和title 对齐居中, 因为 title 长度不固定. 所以假设要几个这样有image有title的button纵向排列 ...