tweepy stream tweets from user
class MyStreamListener(tweepy.StreamListener):
def on_status(self, status):
if from_creator(status):
try:
# Prints out the tweet
print(status.text)
# Saves tweet into a file
with open("Test.txt", 'a') as file:
file.write(status.text)
return True
except BaseException as e:
print("Error on_data %s" % str(e))
return True
return True
def on_error(self, status_code):
if status_code == 420:
print("Error 420")
#returning False in on_error disconnects the stream
return False