Skip to content

Instantly share code, notes, and snippets.

@codafon655
Created November 7, 2021 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codafon655/28579e8ef166bfbbc5c5b521635d6daa to your computer and use it in GitHub Desktop.
Save codafon655/28579e8ef166bfbbc5c5b521635d6daa to your computer and use it in GitHub Desktop.
import tweepy
import csv
consumer_key=''
consumer_secret=''
access_token_key=''
access_token_secret=''
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token_key, access_token_secret)
api = tweepy.API(auth)
######################
with open('xxxxxxxx.csv','w', newline="") as f:
writer = csv.writer(f)
#my_info = api.me()
friends_ids = []
# フォローした人のIDを全取得user_id=my_info.id
# Cursor使うとすべて取ってきてくれるが,配列ではなくなるので配列に入れる
for friend_id in tweepy.Cursor(api.friends_ids, id='Codafon_655').items():
friends_ids.append(friend_id)
#writer.writerow([friend_id])
print("ui")
val = input()
# 100IDsずつに詳細取得
cou=0
for i in range(0, len(friends_ids), 100):
for user in api.lookup_users(user_ids=friends_ids[i:i+100]):
#print(user.name + " ::: @" + user.screen_name)
writer.writerow(["w"+str(user.id),user.friends_count,user.followers_count,user.friends_count/user.followers_count,"https://twitter.com/intent/user?screen_name="+str(user.screen_name)])
cou+=1
if cou%1000==0:
print("ui")
val = input()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment