Search code examples
pythonapitwittertweepy

Python Tweepy - limit doesn't work properly


i am trying to scrape data with Tweepy, but i find out, that the limit is not working properly and i don't know, why.

user = 'LudekStanek'
limit = 1
api = tweepy.API(auth)

search = api.user_timeline(screen_name = user,count = limit, include_rts = False, exclude_replies=True,tweet_mode='extended')
print(f"Number of tweets {len(search)}")

This works fine, i get just one tweet.

But when i put tu limit number 4, it scrapes 1 tweet. With 10 limit, its 3 tweets. With 3000 , it scrapes 121 tweets. (I know that the maximum limit is 200)

Can you please explain me, how it works this parameter?

Because in some case with limit 3000 it scrapes only 25 tweets (but the user posted more then 1000 tweets).

Thanks!


Solution

  • This is probably because you have set include_rts to False and exclude_replies to True. Even if you don't receive the RT and the replies, they are deducted from the count.