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

2024-04-27 05:17:33 发布

您现在位置:Python中文网/ 问答频道 /正文

在python3和tweepy中,我有一个脚本在Twitter上执行hashtags搜索:

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
[]

结果是一个空列表。拜托,有人知道问题出在哪里吗?你知道吗


Tags: keytest脚本tokenauthapisearchsecret
1条回答
网友
1楼 · 发布于 2024-04-27 05:17:33
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

相关问题 更多 >