Python 2.7 如何在Tweepy中增加Twitter API访问的搜索词数量?

Python 2.7 如何在Tweepy中增加Twitter API访问的搜索词数量?,python-2.7,twitter,tweepy,Python 2.7,Twitter,Tweepy,我发现我只能用下面的代码包含多达20多个搜索词,然后它给了我一个错误,说有太多的搜索词。有什么办法绕过它吗 import tweepy searchTerms = '1' or '2' or '3' # to say ... '99' or '100' tweets = tweepy.Cursor(api.search, q=searchTerms, since=startSince, until=endUntil).items() 根据推特的说法,q参数是有限的 UTF-8,URL编码的搜索

我发现我只能用下面的代码包含多达20多个搜索词,然后它给了我一个错误,说有太多的搜索词。有什么办法绕过它吗

import tweepy
searchTerms = '1' or '2' or '3' # to say ... '99' or '100'
tweets = tweepy.Cursor(api.search, q=searchTerms, since=startSince, until=endUntil).items()
根据推特的说法,
q
参数是有限的

UTF-8,URL编码的搜索查询,最多500个字符,包括运算符。查询还可能受到复杂性的限制

如果您想构建复杂的搜索词逻辑,可以使用and侦听器。你基本上是在做你自己的过滤。下面是一个简单的侦听器示例。我试图给出一些从
on_status
方法返回的流行对象,这些对象作为
json
返回

import json

class SListener(StreamListener):

    def __init__(self, api = None, fprefix = 'streamer'):
        self.api = api or API()
        self.counter = 0
        self.fprefix = fprefix

    def on_data(self, data):
        elif 'limit' in data:
            if self.on_limit(json.loads(data)['limit']['track']) is False:
                return False
        elif 'warning' in data:
            warning = json.loads(data)['warnings']
            print warning['message']
            return false

    def on_status(self, status):

        status_obj = json.loads(status)

        username = status_obj["user"]["screen_name"]
        userID = status_obj["user"]["id"]
        user_loc = status_obj["user"]["location"]
        tweet_date_time = status_obj["created_at"]
        tweetID = status_obj["id"]

        tweet = status_obj["text"].encode('utf-8')
        searchTerms = ['1','2','3'] # to say ... '99' or '100'

        if any(query in tweet for query in searchTerms):
            print(tweet) #or do something with it