如何在tweepy中搜索多个字符串?

时间:2019-01-08 12:53:09

标签: python tweepy

在Python 3和tweepy中,我使用以下脚本在Twitter上进行主题标签搜索:

import tweepy

consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

#test = api.get_user('some user')._json
#test
#The test worked

search_result = api.search('#maconhamedicinal' or '#cannabismedicinal')
search_result
[]

结果为空列表。拜托,有人知道是什么问题吗?

1 个答案:

答案 0 :(得分:2)

keywords = ['#maconhamedicinal','#cannabismedicinal']
results = []
for key in keywords:    
    search_results = api.search(q=key, count=100)
    results = results + search_results
for result in results:
    # do whatever u wanna do