-
I am coding a twitter bot which join giveaways of users that I follow. The problem is that when I use a for loop to iterate a ItemIterator Cursor of 50 items it breaks before finishing. It usually does 20 or 39-40 iterations. My main function is:
So when the loop do usually 39 iterations, the code jumps into the 15min cooldown getting these of tweets: len(tweets.current_page) - 1 tweets.page_index tweets.limit tweets.num_tweets I've seen this in the tweepy cursor.py but I still don't know how to fix it.
When I've tried test codes like
j and tweets.num_tweets are almost always 100, but I think when this is not 50 is because I dont wait between request, because I've reached j=300 with this, so maybe the problem is in the check function: (It's a previous check function which also has the same problem, I've noticed it when I've started getting stats, the only difference is that I return values if the tweets has been liked, rt, etc)
This is the first time I asked help so I dont know if I've post all the info needed, this is driving me mad since last week and I dont know who to ask :( Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Is there an error? If so, what's the full traceback? |
Beta Was this translation helpful? Give feedback.
-
The
This is a limitation of this Twitter API endpoint, as there's not another good way to determine when to stop paginating. However, you can pass a higher |
Beta Was this translation helpful? Give feedback.
The
IdIterator
thatCursor
returns when used withAPI.home_timeline
stops when it receives a page with no results. This is most likely what's happening, since the defaultcount
for the endpoint is 20 and:https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-home_timeline
This is a limitation of this Twitter API endpoint, as there's not another good way to determine when to stop paginating.
However, you can pass a higher
count
(e.g. 100 if that works for you, up to 200) to the endpo…