Hello there , i have been facing this issue that i start the streaming from tweepy and getting tweets. i have tested my code on console and on the website ,
- on the console it will run for hours
- on the website it only runs for 5min
The Error is This :
Error 504 Gateway Time-out
the Code is This :
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
import tweepy
import datetime
##################################################
##################################################
# Autontication Keys from Twitter api --- (DO NOT CHANGE)
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
streaming = []
class StdOutListener(StreamListener):
def on_status(self, status):
tweet = status.text.encode('ascii', 'ignore')
tweet = tweet.replace('\n', '\\n')
streaming.append({"text": tweet})
return True
def on_error(self, status):
streaming.append(status)
return False
def on_limit(self, status):
streaming.append(status)
return False
def on_timeout(self, status):
streaming.append(status)
return False
def on_disconnect(self, notice):
streaming.append(notice)
return False
l = StdOutListener()
stream = Stream(auth, l)
stream.filter(track=['basketball'], languages=["en"])
print streaming
The code works for interval under 5min if i force the streaming to stop i can get the tweets but i want it to work for more than 5min where it should but this Error stopping it no idea why , idk if this is from the host or from twitter api.