user.get_following(), user.get_followers() only returns 70 users.
Closed this issue · 1 comments
iribeirocampos commented
Hi, I´m trying to get all users followers or following, however, the 2 functions only return 70 users regardless of the value I set in count.
no_count =user.get_following()
fifty = user.get_following(count=50)
hundred = user.get_following(count=100)
print(no_count)
print(fifty)
print(hundred)
OUTPUT:
70
70
70
The user I'm using for testing has more then 5000 followings.
d60 commented
Hi, @iribeirocampos
The number of followers that can be obtained at once from the API is limited, and it's not possible to retrieve all followers in one go. Instead, you can use the next method to fetch all followers.
Here is an example code:
import os
from twikit import Client
AUTH_INFO_1 = '...'
AUTH_INFO_2 = '...'
PASSWORD = '...'
client = Client()
if os.path.exists('cookies.json'):
client.load_cookies('cookies.json')
else:
client.login(
auth_info_1=AUTH_INFO_1,
auth_info_2=AUTH_INFO_2,
password=PASSWORD
)
client.save_cookies('cookies.json')
user_id = '...' # User ID here
followers = client.get_user_followers(user_id)
all_followers = []
while len(followers) > 0:
all_followers += followers
try:
followers = followers.next()
except:
pass
print(all_followers)