4

我正在使用状态/过滤器,并试图根据参数“filter_level”过滤来自推特流的推文。

query = ["Donald Trump","Cristiano Ronaldo"]

numberOfTweets = 1000
dictOfTweets ={}
twitter_api = oauth_login()
twitter_stream = twitter.TwitterStream(auth=twitter_api.auth)

for q in query:
  stream =  twitter_stream.statuses.filter(track=q,max_count=numberOfTweets,languages= ['en'],filter_level=['medium'])
  for tweet in stream:
      if tweet.get('text',0) == 0:
          continue
      dictOfTweets.setdefault(q,[]).append(tweet['text'])

我仍然收到带有 filter_level =“low”的推文。如果有人可以建议我错过了什么或做错了什么,那将非常有帮助?

4

1 回答 1

0

你需要把 (languages= ['en'],filter_level=['medium']) while Authentication

query = ["Donald Trump","Cristiano Ronaldo"]

numberOfTweets = 1000
dictOfTweets ={}
twitter_api = oauth_login()
twitter_stream = twitter.TwitterStream(auth=twitter_api.auth, ,languages= ['en'],filter_level=['medium'])

for q in query:
  stream =  twitter_stream.statuses.filter(track=q,max_count=numberOfTweets)
  for tweet in stream:
      if tweet.get('text',0) == 0:
          continue
      dictOfTweets.setdefault(q,[]).append(tweet['text'])
于 2019-04-16T14:08:01.733 回答