how to find the user corresponding to a searched-for tweet using tweepy / python?

98 views
Skip to first unread message

MM

unread,
Mar 14, 2014, 10:40:31 PM3/14/14
to twe...@googlegroups.com
Here is my code:

CONSUMER_KEY = 'xxx'

CONSUMER_SECRET = 'xxx' # Make sure access level is Read And Write in the Settings tab

ACCESS_KEY = 'xxx'

ACCESS_SECRET = 'xxx'

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)

auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)

api = tweepy.API(auth)


search_results = tweepy.API.search(api, 'hi', show_user = True)

print search_results


for tweet in search_results:

try:

print 'tweet:', tweet.from_user

except:

print 'fail'

finally:

pass


I am able to search for tweets and print them out (if I do print tweet.text then I see tweets) but I can't figure out how to see the user that tweeted these tweets.  I've been searching through the docs for hours - what am I missing?!

Aaron Hill

unread,
Mar 20, 2014, 6:32:16 AM3/20/14
to twe...@googlegroups.com
You can use the `user` attribute of a Tweet object, like this:

`tweet.user`

Aaron Hill

unread,
Mar 20, 2014, 6:50:12 AM3/20/14
to twe...@googlegroups.com
You can uswvthe `user` attribute, like this:

`tweet.user`

Reply all
Reply to author
Forward
0 new messages