Last active
April 26, 2019 15:18
-
-
Save josircg/b4bab8de92908a50b9359e4b51759405 to your computer and use it in GitHub Desktop.
Example of Tweepy search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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