Search code examples
pythontwittertweepytweets

How to get the whole tweet using tweepy instead of part of the tweet with a link


Firstly, I do realize that there's a similar question but using the Twython library, not Tweepy. Also, I have seen How to get the full text of a tweet using tweepy? But, adding , tweet_mode='extended' after count=count below gives me an error: AttributeError: 'Status' object has no attribute 'text' Here is what I have:

fetched_tweets = api.search(q, lang = 'en', count=count)

for tweet in fetched_tweets:
    parsed_tweet = {}
    parsed_tweet['text'] = tweet.text

    line = re.sub('@[\w]+', '', tweet.text)
    target.write(line+"\n")
    target.write("--------------------------------------------------------------\n")
    tweets.append(line)

So, I am creating a list of these tweets, however some of the tweets appear as the following:

ADAM ARON CONFIRMED IF WE VOTE YES ON THE 500M, AMC PLEDGES NOT TO DILUTE ANY OF IT IN CALENDAR YEAR 2021.

GIVE TH… h t t p s : / / t . c o / t D i T u x f d F g (I had to add spaces between the letters of the link)

It should instead read:

ADAM ARON CONFIRMED IF WE VOTE YES ON THE 500M, AMC PLEDGES NOT TO DILUTE ANY OF IT IN CALENDAR YEAR 2021.

GIVE THAT MAN HIS SHARES.

Within the legal confines of being a CEO, he is on our side and wants the same thing we do.

changing my vote to Yes.

$amc #amc


Solution

  • To solve this problem, I was able to change fetched_tweets = api.search(q, lang = 'en', count=count) to fetched_tweets = api.search(q, lang = 'en', count=count, tweet_mode='extended'), and also change tweet.text to tweet.full_text.