Getting Full Tweet Text From "user_timeline" With Tweepy
I am using tweepy to fetch tweets from a user's timeline using the script included here. However, the tweets are coming in truncated: auth = tweepy.OAuthHandler(consumer_key, consu
Solution 1:
Instead of full_text=True you need tweet_mode="extended"
Then, instead of text you should use full_text to get the full tweet text.
Your code should look like:
new_tweets = api.user_timeline(screen_name = screen_name,count=200, tweet_mode="extended")
Then in order to get the full tweets text:
tweets = [[tweet.full_text] for tweet in new_tweets]
Solution 2:
Manolis's answer is good but not complete. To get the extended version of a tweet (as in Manoli's version), you would do :
tweetL = api.user_timeline(screen_name='sdrumm', tweet_mode="extended")
tweetL[8].full_text
'Statement of the day at #WholeChildSummit2019 - “‘SOME’ is not a number, and ‘SOON’ is not a time!” IMO, this is why educational systems get stuck. Who in your system will initiate change? TODAY! #HSEFutureReady'
However, if this tweet is a retweet, you'll want to use the retweets' full text:
tweetL = api.user_timeline(id=2271808427, tweet_mode="extended")
# This is still truncated
tweetL[6].full_text
'RT @blawson_lcsw: So proud of these amazing @HSESchools students who presented their ideas on how to help their peers manage stress in mean…'
# Use retweeted_status toget the actual full text
tweetL[6].retweeted_status.full_text
'So proud of these amazing @HSESchools students who presented their ideas on how to help their peers manage stress in meaningful ways! Thanks @HSEPrincipal for giving us your time!'
This was tested with Python 3.6
and tweepy-3.6.0
.
Post a Comment for "Getting Full Tweet Text From "user_timeline" With Tweepy"