-
-
Save alfard/15bd8c58df93af548dd2 to your computer and use it in GitHub Desktop.
History_tweet
This file contains 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 | |
import time | |
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) | |
a=[] | |
page_count = 0 | |
for tweet in tweepy.Cursor(api.search, | |
q="NKM", | |
count=25, | |
result_type="recent", | |
include_entities=True, | |
lang="fr").items(): | |
page_count += 1 | |
#Enregistrement dans la matrice a des tweets | |
a.append([tweet.created_at,tweet.text]) | |
print len(a) | |
time.sleep(0.2) | |
#Pour respecter la fréquence imposée par l'api, je fais une pause de 0.2 secondes entre | |
#chaque résultat | |
if tweepy.TweepError is "[{u'message': u'Over capacity', u'code': 130}]": | |
print "Over capacity" | |
time.sleep(2000) | |
if tweepy.TweepError is "[{u'message': u'Internal error', u'code': 131}]": | |
print "Internal error" | |
time.sleep(2000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment