I can't find a way to get the full text of a tweet, I have everything activated, tweet_mode="extended" and I print tweet.full_text, but it keeps getting the trimmed tweet, I've looked directly at tweet._json and it's also trimmed there I don't understand why
import tweepy
import configparser
from datetime import datetime
def apiTwitter(): #Para conectarse a twitter y scrapear con su api, devuelve objeto de tweepy cheto para scrapear twitter
# read credentials
config = configparser.ConfigParser()
config.read('credentialsTwitter.ini')
api_key = config['twitter']['api_key']
api_key_secret = config['twitter']['api_key_secret']
access_token = config['twitter']['access_token']
access_token_secret = config['twitter']['access_token_secret']
# authentication
auth = tweepy.OAuthHandler(api_key,api_key_secret)
auth.set_access_token(access_token,access_token_secret)
api=tweepy.API(auth)
return api
api=apiTwitter() #Con api ahora podemos scrapear todo twitter de forma sencilla
tweets = api.user_timeline(screen_name='kowaalski_',tweet_mode="extended", count=1)
tweet=tweets[0]
#print(tweet._json)
print(f'Tweet text: {tweet.full_text}')
This is because the first tweet is a retweet and the full_text
attribute of a retweet can still be truncated. You have to access the full_text
attribute of the retweeted status instead.
Basic example:
try:
print(tweet.retweeted_status.full_text)
except AttributeError: # So this is not a Retweet
print(tweet.full_text)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.