Reputation: 37
I have created a streaming program in Python to receive Tweets, however I notice it only returns part of the text of the tweet. I have looked at similar problems, and know I must insert 'tweet_mode="extended"' somewhere, and have inserted it into Stream, but it doesn't seem to work.
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
class MyListener(StreamListener):
def on_data(self, data):
with open(file_name, "a") as file:
tweetDict = {"text": "", "coordinates": ""}
tweet = json.loads(data)
json.dump(tweet, file, indent=4)
file.write("\n")
return True
twitter_stream = Stream(auth, MyListener(), tweet_mode="extended")
twitter_stream.filter(track=[target])
Upvotes: 0
Views: 75
Reputation: 581
The full tweet is in the json response.
You can find it under:
tweet = json.loads(data)
tweet["retweeted_status"]["extended_tweet"]["full_text"]
Upvotes: 1