2011-11-09 69 views
3

有沒有辦法訪問列表中的所有成員? 目前,我只能看到前20名成員? 具體來說,我使用python和tweepy。如何獲取列表Twitter API中的所有用戶?

+0

如果僅僅有一個BigQuery資料表的話,甚至有一個導出腳本https://github.com/twitterdev/twitter-for-bigquery GitHub的存檔做它的GitHub例如https://www.githubarchive.org/ –

+0

@self:也許它是針對Twitter的ToS:https://twittercommunity.com/t/can-i-release-mined-tweets-for-research/13463 –

回答

6

在Tweepy中,可以通過使用Tweepy提供的Cursor類來實現此功能,該功能根據所需的方法調用爲返回給您的模型實現適當的迭代器。在你的情況下,你想用list_members()方法和參數爲列表所有者和列表slug初始化一個Cursor(見https://dev.twitter.com/docs/api/1/get/lists/members)。

例(從http://packages.python.org/tweepy/html/code_snippet.html#pagination修改):

import tweepy 
api = tweepy.API() # Don't forget to use authentication for private lists/users. 

# Iterate through all members of the owner's list 
for member in tweepy.Cursor(api.list_members, 'list_owner', 'slug').items(): 
    # Do something with member... 

我希望我能聯繫你一些了最新的文檔,但我能找到的唯一的事情就是這個版本1.4 documentation about using Cursors。該策略仍然是對Tweepy中Twitter API資源的結果進行分頁/迭代的推薦方式。

0

試試:

user = tweepy.api.get_user('you or nick') 

print user.screen_name 
print user.followers_count 

for friend in user.friends(): 
    print friend.screen_name 
相關問題