Tweepy流媒体模块语言筛选器不工作



我正在尝试以下代码以法语提取tweet,但它以英语和其他一些语言返回tweet。是否存在语法错误?

import sys
import tweepy
import config as config
consumer_key= config.CONSUMER_KEY
consumer_secret= config.CONSUMER_SECRET
access_key = config.OAUTH_TOKEN
access_secret = config.OAUTH_TOKEN_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):
        print status.lang
            #, status.user.location, status.user.description
    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=["rame", "lent", "long", "beug", "beugg", "beugge", "bug"], languages = ["fr"])

这是一篇旧帖子,但我最近遇到了同样的问题:关键字搜索似乎无法正常工作,即使没有关键字,它似乎也会返回推文。对我有效的解决方案是使用twython和API v2…

尝试使用语言而不是s语言。

最新更新