嗨,我正在尝试使用tweepy来传输来自Twitter的实时tweet。我有以下代码,但我想删除过滤器属性。无论过滤器如何,我都想获取该推文。我该怎么办?
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
import time
import sys
ckey = '<consumer key>'
csecret = '<consumer secret>'
atoken = '<access token>'
asecret = '<access token secret>'
class listener(StreamListener):
def on_data(self,data):
try:
saveFile = open('twitDB.csv','a')
saveFile.write(data)
saveFile.close()
return True
except BaseException,e:
print ('failed ondata, ',str(e))
time.sleep(5)
def on_error(self,status):
print (status)
auth = OAuthHandler(ckey,csecret)
auth.set_access_token(ato]ken,asecret)
twitterStream = Stream(auth,listener())
twitterStream.filter(track=["car"])