I want to search the tweets, extract the screen_name from the statuses and use that to get the past favorite tweets of that screen_name. Now I donot know how to extract the screen_names from statuses and then how to use to get past favorites. This is my code(the problem is with the last line):
import tweepy
consumer_key = ''
consumer_secret = ''
access_token = ''
access_secret = ''
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
api = tweepy.API(auth)
search_results = tweepy.Cursor(api.search,q="Ganesh World").items()
for i in search_results:
print i.text.encode('utf-8')
print api.favorites([i.screen_name])
It is throwing AttributeError:Status object has no attribute 'screen_name'
No need to waste another API call, You can fetch it from inner data elements, i.e. from author , and within that from its json like this:
for i in search_results:
print i.author._json['screen_name']