I have the code to grab a specific users followers as shown below. What I would like to do to further this is not just grab a user's followers but also the followers own followers. An example would be to grab Carl Icahns followers id's and then get those followers own followers id's. So if I am following Carl Icahn, I would be able to retrieve all of my followers as well. Also, for some reason I am grabbing the same 5000 followers each call for some reason instead of getting a different 5000 every time. Can anyone please help me with this? I would greatly appreciate it.
import logging
import time
import csv
import twython
import json
app_key = "**********"
app_secret = "**********"
oauth_token = "***********"
oauth_token_secret = "**************"
twitter = twython.Twython(app_key, app_secret, oauth_token, oauth_token_secret)
followers = twitter.get_followers_ids(screen_name = "Carl_C_Icahn")
for follower_id in followers:
print ("Carl Icahn followers:", followers)
with open('carlfollowers.txt', 'a') as outfile:
json.dump(followers, outfile, sort_keys = True, indent = 4)