Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Tweepy search_users returns only 50 records

I am looking to search twitter for all users with a keyword in their user name. I am doing this by:

api = tweepy.API(auth, wait_on_rate_limit= True)

def get_users():
count = 0
all_users = []
for page in tweepy.Cursor(api.search_users,["keyword"]).pages():
    #page[0] has the UserObj
    id_str = page[0].id_str
    scr_name = page[0].screen_name
    print(count, id_str)

This is working, but it is only returning the first 50 results. How do I return a larger set of results? Say upwards of 2000?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

First of all, you can retrieve only the first 1000 users with the API (see here).

Then, why are you only using the page[0] ? There are 20 users par page, not only one. My bet would be that this is why you have this problem (you can get only 1000 users, so that means 50 pages if you get 20 users per page, so 50 users if you read only the first user of each page).

By the way, you could use .items() instead of .pages().

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading