Getting full tweet text from "user_timeline" with tweepy

atkat12 picture atkat12 · Mar 9, 2017 · Viewed 15.1k times · Source

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, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tweepy.API(auth)
new_tweets = api.user_timeline(screen_name = screen_name,count=200, full_text=True)

Returns:

Status(contributors=None, 
     truncated=True, 
     text=u"#Hungary's new bill allows the detention of asylum seekers 
          & push backs to #Serbia. We've seen push backs before so\u2026 https:// 
          t.co/iDswEs3qYR", 
          is_quote_status=False, 
          ...

That is, for some i, new_tweets[i].text.encode("utf-8") appears like

#Hungary's new bill allows the detention of asylum seekers & 
push backs to #Serbia. We've seen push backs before so…https://t.co/
iDswEs3qYR

Where the ... in the latter replaces text that would normally be displayed on Twitter.

Does anyone know how I can override truncated=True to get the full text on my request?

Answer

Manolis Kyriakakis picture Manolis Kyriakakis · May 20, 2017

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]