Tweepy: Truncated Tweets When Using Tweet_mode='extended'
This is my code in python import tweepy import csv consumer_key = '?' consumer_secret = '?' access_token = '?' access_token_secret = '?' auth = tweepy.OAuthHandler(consumer_key,
Solution 1:
I've had the same problem as you recently, this happened for the retweets only, I found that you can find the full text under here: tweet._json['retweeted_status']['full_text']
Code snippet:
...
search_tweets = api.search('trump',count=1,tweet_mode='extended')
for tweet in search_tweets:
if'retweeted_status'in tweet._json:
print(tweet._json['retweeted_status']['full_text'])
else:
print(tweet.full_text)
...
EDIT Also please note that this won't show RT @....
at the beginning of the text, you might wanna add RT
at the start of the text, whatever suits you.
EDIT 2 You can get the name of the author of the tweet and add it as the beginning as follows
retweet_text = 'RT @ ' + api.get_user(tweet.retweeted_status.user.id_str).screen_name
Solution 2:
This worked for me :
if'retweeted_status'instatus._json:
if'extended_tweet'instatus._json['retweeted_status']:
text = 'RT @'+status._json['retweeted_status']['user']['screen_name']+':'+status._json['retweeted_status']['extended_tweet']['full_text']
else:
text = 'RT @'+status._json['retweeted_status']['user']['screen_name']+':' +status._json['retweeted_status']['text']
else:
if'extended_tweet'instatus._json:
text = status._json['extended_tweet']['full_text']
else:
text = status.text
Post a Comment for "Tweepy: Truncated Tweets When Using Tweet_mode='extended'"