Tweepy user id from mention

I use tweepy to set up a script that finds the last mention of my username. From this I want to get the tweet text and Twitter username. However, I seem to be unable to get the actual username, but only its number. Any suggestions?

Below is my code. Question marks are where I need the correct syntax:

 myMentions = tweepy.Cursor (api.mentions).items(1) for mention in myMentions: statusText = mention.text statusUser = mention.???? 

Thank you very much!

+6
source share
1 answer

Here's what works for me with the latest version of tweepy :

 import tweepy auth = tweepy.OAuthHandler(<consumer_key>, <consumer_secret>) auth.set_access_token(<key>, <secret>) api = tweepy.API(auth) mentions = api.mentions_timeline(count=1) for mention in mentions: print mention.text print mention.user.screen_name 

Hope this helps.

+9
source

Source: https://habr.com/ru/post/944286/


All Articles