我想使用关键字流式传输泰米尔语推文。例如,我需要流式传输包含单词“கனா”的推文。我编写了一些代码,但无法流式传输包含该关键字的所有推文。它返回一些推文。如何解决这个问题?
access_token = "ENTER YOUR ACCESS TOKEN" access_token_secret = "ENTER YOUR ACCESS TOKEN SECRET" consumer_key = "ENTER YOUR API KEY" consumer_secret = "ENTER YOUR API SECRET"
class StdOutListener(StreamListener):
def on_data(self, data):
op.write(data)
return True
def on_error(self, status):
print(status)
# This handles Twitter authetification and the connection to Twitter Streaming API
l = StdOutListener() auth = tweepy.OAuthHandler(consumer_token, consumer_secret) auth.set_access_token(access_token, access_secret) stream = Stream(auth, l)
api = tweepy.API(auth, wait_on_rate_limit=True)
query = "கனா"
# Language code (follows ISO 639-1 standards)
language = "ta"
# Calling the user_timeline function with our parameters
a = api.search(q=query, lang=language)