对推文应用限制

时间:2018-07-10 06:58:21

标签: python tweepy data-retrieval

我正在尝试使用tweepy在python中获取twitters数据,我想设置返回的tweet数量。 这是我的代码块

class StdOutListener(StreamListener):

    def on_data(self, data):
        print (data)
        return True

    def on_error(self, status):
        print (status)


if __name__ == '__main__':

    #This handles Twitter authetification and the connection to Twitter Streaming API
    l = StdOutListener()
    auth = OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_key, access_secret)
    stream = Stream(auth, l)
    #This line filter Twitter Streams to capture data by the keywords: 'python', 'javascript', 'ruby'
    stream.filter(track=['hello', 'javascript', 'python'])

1 个答案:

答案 0 :(得分:0)

Tweepy提供了方便的Cursor接口来迭代不同类型的对象。 Twitter最多允许提取3200条推文。

将标准页中的返回推文设置为50:

tweets = api.search(q="place:%s" % place_id, rpp=50)