'Error when trying to get full_text for a Tweet using Tweepy and Python
I am trying to use Tweepy and streaming to track Tweets in real time. I am using the following which works fine:
import tweepy
import configparser
import sys
#read configs
config = configparser.ConfigParser()
config.read('config.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']
class StreamCollector(tweepy.Stream):
def on_status(self, status):
if not hasattr(status, 'retweeted_status') and status.in_reply_to_screen_name == None and status.i\
s_quote_status == False:
if status.author.followers_count > 100000:
print('Twitter Handle: @'+status.author.screen_name)
print('Followers:',status.author.followers_count)
print('Tweet:',status.text)
print('\n')
#print(status.user.screen_name.encode('UTF-8'))
stream = StreamCollector(api_key,api_key_secret,access_token, access_token_secret)
stream.filter(track=["table"])
However, I want to produce the untruncated Tweet. I tried substituting status.text for status.full_text but I got the error:
AttributeError: 'Status' object has no attribute 'full_text'
My version of Tweepy is 4.5.0 and Python is 3.9.9.
Solution 1:[1]
Streaming is covered in Tweepy's documentation on extended Tweets:
By default, the Status objects from streams may contain an
extended_tweetattribute representing the equivalent field in the raw data/payload for the Tweet. This attribute/field will only exist for extended Tweets, containing a dictionary of sub-fields. Thefull_textsub-field/key of this dictionary will contain the full, untruncated text of the Tweet
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Harmon758 |
