0
The function getting_friends_follwers()
below works if I remove the value 100 from (cursor2.items(100))
. My goal is to take these names (followers and friends) and save in a file "friends.txt".
The problem: The name screen_name
has a huge amount of friends and followers and thus the connection is terminated by Twitter. I thought about trying to capture the names from 100 to 100 (hence the value 100 in the cursor2 call) but the following error occurs:
builtins.TypeError: '<' not supported between instances of 'User' and 'User'
How to correct?
f = open("amigos.txt","w")
Meu = []
def getting_friends_follwers():
# Get list of followers and following for group of users tweepy
cursor = tweepy.Cursor(api.friends, screen_name="Carlos")
cursor2 = tweepy.Cursor(api.followers, screen_name="Carlos")
## for user in cursor.items():
## print('friend: ' + user.screen_name)
for user in sorted(cursor2.items(100)):###funciona se eu tirar este valor!!!
f.write(str(user.screen_name)+ "\n")
print('follower: ' + user.screen_name)
f.close()
getting_friends_follwers()
I don’t know the tweepy so well, but that mistake must be because of the
sorted
, because it cannot compare the users returned by cursor to order them– hkotsubo