d60 / twikit

Twitter API Scraper | Without an API key | Twitter Internal API | Free | Twitter scraper | Twitter Bot
https://twikit.readthedocs.io/en/latest/twikit.html
MIT License
1.5k stars 176 forks source link

get_user_following retrieves only 50 follows #256

Closed itoma-aikon closed 1 week ago

itoma-aikon commented 1 week ago

I want to use get_user_following to get a list of followers, but when I tweak the count I only get 50.

import asyncio
from twikit import Client

client = Client(
    language = 'ja-JP',
)

async def main():
    client.load_cookies('cookies.json')
    following = await client.get_user_following(user_id=xxxx,count=100)
    print(len(following))
    for user in following:
        print(f"username:{user.name} userID:{user.screen_name} (ID: {user.id})")

asyncio.run(main())
brownepres commented 1 week ago

Use following_new = await following.next() to retrieve the next batch of followers. Put it in a loop to automate it

itoma-aikon commented 1 week ago

Thank you!! I followed the instructions and was successful. I got the following code.

import asyncio
from twikit import Client

client = Client(
    language = 'ja-JP',
)

async def main():
    client.load_cookies('cookies.json')
    following = await client.get_user_following(user_id=xxxx,count=100)    
    while following:
        for user in following:
            print(f"username:{user.name} userID:{user.screen_name} (ID: {user.id})")
        following = await following.next()

asyncio.run(main())