0

I tried printing my twitter friendlist.I have 112 friends but i am able to print screennames of only 20 friends. Is it because of some API limit/difference between friends and following/conceptual error.This is my code:

import tweepy
import sys
import time
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
data = api.get_user('')

count = 0
for friend in data.friends():
        print 'Friend:'+ friend.screen_name
        count=count+1
        if count%5==0:
            print count
        time.sleep(20)

My interpreter is not throwing any error.

Abhishek Sharma
  • 1,909
  • 2
  • 15
  • 24

1 Answers1

1

By default Twitter returns 15 records per call. To get more:

  • ask Tweepy for more (count=100) -- doc

or

  • use a Cursor to iterate over all the data; see Tutorial
Community
  • 1
  • 1
johntellsall
  • 14,394
  • 4
  • 46
  • 40