Skip to content

Instantly share code, notes, and snippets.

@thiagodeschamps
Forked from marcoscastro/exemplo_tweepy.py
Last active December 20, 2018 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagodeschamps/9348d39cb2bff32174b0163d9b4ae023 to your computer and use it in GitHub Desktop.
Save thiagodeschamps/9348d39cb2bff32174b0163d9b4ae023 to your computer and use it in GitHub Desktop.
Obtendo tweets de usuário com Python e tweepy
import tweepy
auth = tweepy.OAuthHandler('46pvnSwIVylfWepbPsP4433wL', 'xWDPHaUkk0ub93qj1DaYgJcO8QtkPUhNFIE7uBAvzbSVLLpLzR')
auth.set_access_token('1952916806-9WbU9ROPLd4aVPprQZqWJhaW4RSXrBw4oK8A4Ow','gW5iuYPtrTxVhPmQxBemsKz6jCAOqbYx1fT0ewKHFyAkG')
api = tweepy.API(auth)
def obter_tweets(usuario, limite):
resultados = api.user_timeline(screen_name=usuario, count=limite)
tweets = []
for r in resultados:
tweets.append(r.text)
return tweets
tweets = obter_tweets('jairbolsonaro',100)
with open('tweets.txt', 'w') as f:
f.write('\n\n\n'.join(tweets))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment