Skip to content

Instantly share code, notes, and snippets.

@josircg
Last active April 26, 2019 15:18
Show Gist options
  • Save josircg/b4bab8de92908a50b9359e4b51759405 to your computer and use it in GitHub Desktop.
Save josircg/b4bab8de92908a50b9359e4b51759405 to your computer and use it in GitHub Desktop.
Example of Tweepy search
import tweepy
# grava um arquivo json para cada item
def save_result(data):
filename = 'data/%s.json' % data['id']
arquivo = open(filename, 'w')
json.dump(data, arquivo)
arquivo.close()
termo_de_busca = 'wikileaks'
auth = tweepy.OAuthHandler(consumer_key='',consumer_secret='')
auth.set_access_token('aaa','aaa')a
api = tweepy.API(auth, wait_on_rate_limit=True)
results = tweepy.Cursor(api.search, q=termo_de_busca, tweet_mode='extended').items()
total = 0
for status in results:
save_result(status._json)
total += 1
if total == 1000:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment