I need to only get the followers I have not fetched before. Currently I can only get the top 200 items or given count but I don't want to get the same data more than once.
Asked
Active
Viewed 201 times
2 Answers
1
The only way I know how is to cycle through them and follow them if they haven't already been followed. I don't believe it's possible by looking at the API:
https://www.geeksforgeeks.org/python-api-followers-in-tweepy/
Make sure you have the third line for the API:
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth, wait_on_rate_limit = True)
Here's my snippet for following:
followers = tweepy.Cursor(api.get_followers).items()
for follower in followers:
if follower.id not in friends:
user = api.get_user(follower.id)
follower.follow()

Nickofthyme
- 3,032
- 23
- 40

Rajiv Baxi
- 11
- 1
0
followers = tweepy.Cursor(api.get_followers).items()
I just discovered that .items() can be passed a number. So you could do something like:
followers = tweepy.Cursor(api.get_followers).items(50)
Additionally, looking at the API documentation, API.get_followers() method, you can also set the number of followers to go through by passing a value to the count variable.
API.get_followers(*, user_id, screen_name, cursor, count, skip_status, include_user_entities)
API.get_followers(count=50)
The followers are returned in the number that they were added.

Rajiv Baxi
- 1
- 1
-
The question is to get only new followers. Not to get paginated followers. Your solution will give all followers whether they are new or old. – Anjayluh Sep 05 '22 at 06:26
-
I don't think you can get only new followers though. You can set the count or items number equal to the number of new followers. Or, you could set the count or items number to slightly higher to ensure that you won't have to constantly adjust before running the script. – Rajiv Baxi Sep 06 '22 at 10:45