How to get the full text of a tweet using tweepy?

前端 未结 1 908
既然无缘
既然无缘 2021-01-27 12:09

I\'m using tweepy.Cursor to extract past tweets of a particular topic, however if the tweet is really long it truncates it. I am using the full_text property to be True, but sti

1条回答
  •  一整个雨季
    2021-01-27 13:05

    you have to explicitly access the field called "full_text". You can try something like this:

    # First you get the tweets in a json object
    results = [status._json for status in tweepy.Cursor(API.search, q="$EURUSD", count=1000, tweet_mode='extended', lang='en').items()]
    
    # Now you can iterate over 'results' and store the complete message from each tweet.
        my_tweets = []
        for result in results:
            my_tweets.append(result["full_text"])
    

    You can extract as much info as you need and then write it into a CSV file or whatever you want.

    I recomend you extract the tweets into a json file so you can easily check all the fields it offers to you.

    Hope it helps!

    Edit: If the retrieved tweet is a RT, the full text will be in result["retweeted_status"]["full_text"]

    0 讨论(0)
提交回复
热议问题