Tweepy Cursor vs Iterative for Low API Calls

I am writing a simple Tweepy application for fun, but it is really limited by the number of API calls I have (somewhere between 150 and 350). Therefore, to take this into account, I am looking for ways to reduce calls. Tweepy has a built-in cursor system. For instance:

# Iterate through all of the authenticated user friends for follower in tweepy.Cursor(api.followers).items(): follower.follow() 

For those who are familiar with this library. Would the above example be more or less effective than just ...

 for follower in api.followers_ids(): api.follow(follower) 

Are there other advantages besides simplicity, using the cursor method over the iterative method?

Thanks in advance.

0
source share
1 answer

If I remember correctly from my use of tweepy , the Cursor object automatically splits into n into many elements ... For example, if there are 10,000 results, and Twitter returns (say) 200 at a time, then all 10,000 will be returned using Cursor , but You will have to make a call to continue searching for the following.

OTOH, api.followers_ids() returns only the first "page" of results, so maybe the first 100 or something else.

+2
source

Source: https://habr.com/ru/post/975566/


All Articles