Skip to content

Instantly share code, notes, and snippets.

@3846masa
Created February 10, 2015 07:27
Show Gist options
  • Save 3846masa/c5accceb541ad8532b58 to your computer and use it in GitHub Desktop.
Save 3846masa/c5accceb541ad8532b58 to your computer and use it in GitHub Desktop.
#!/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