我的代码类似于下面的代码,并且想知道在不降低性能的情况下我可以在过滤器中添加多少个关键字。我意识到答案将取决于影响计算机性能的几个因素,如处理器速度,连接速度和发送计算机等,但Twitter会接受多少?还有一个经验法则来确定从发送计算机中有多少?我想要3000左右。那太多了吗?
import sys
import tweepy
consumer_key = ''
consumer_secret = ''
access_key = ''
access_secret = ''
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tweepy.API(auth)
class CustomStreamListener(tweepy.StreamListener):
def on_status(self, status):
x = str(status)
words = x.split()
for word in words:
screen_name = status.user.screen_name
user_id = status.user.id
tweet = status.text
print word, " | ", screen_name," | ", user_id
print tweet
def on_error(self, status_code):
print >> sys.stderr, 'Encountered error with status code:', status_code
return True # Don't kill the stream
def on_timeout(self):
print >> sys.stderr, 'Timeout...'
return True # Don't kill the stream
sapi = tweepy.streaming.Stream(auth, CustomStreamListener())
sapi.filter(track=['filter1', 'filter2'])