Created
February 10, 2015 07:27
-
-
Save 3846masa/c5accceb541ad8532b58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import tweepy | |
# ログイン設定 | |
twitter_conf = { | |
'consumer' : { | |
'key' : "consumer_key", | |
'secret' : "consumer_secret" | |
}, | |
'access' : { | |
'key' : "access_key", | |
'secret' : "access_secret" | |
} | |
} | |
# 認証 | |
auth = tweepy.OAuthHandler( | |
twitter_conf['consumer']['key'], | |
twitter_conf['consumer']['secret']) | |
auth.set_access_token( | |
twitter_conf['access']['key'], | |
twitter_conf['access']['secret']) | |
# tweepy初期化 | |
api = tweepy.API(auth) | |
my_info = api.me() | |
friends_ids = [] | |
# フォローした人のIDを全取得 | |
# Cursor使うとすべて取ってきてくれるが,配列ではなくなるので配列に入れる | |
for friend_id in tweepy.Cursor(api.friends_ids, user_id=my_info.id).items(): | |
friends_ids.append(friend_id) | |
# 100IDsずつに詳細取得 | |
for i in range(0, len(friends_ids), 100): | |
for user in api.lookup_users(user_ids=friends_ids[i:i+100]): | |
print unicode(user.name) + " ::: @" + unicode(user.screen_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment