Reinaldo Chaves
Reinaldo Chaves

Reputation: 993

How to search tweepy for more than one string?

In Python 3 and tweepy I have this script to do hashtags searches on 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
[]

The result is an empty list. Please, does anyone know what the problem is?

Upvotes: 0

Views: 284

Answers (1)

Chandu
Chandu

Reputation: 2129

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

Upvotes: 1

Related Questions