Created
April 21, 2016 17:50
-
-
Save SIRHAMY/237bc3928e535e55ab49dabfa30acdb0 to your computer and use it in GitHub Desktop.
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 time | |
import tweetpony | |
self.twitAPI = tweetpony.API(consumer_key = env.TWITTER_CONSUMER_KEY, | |
consumer_secret = env.TWITTER_CONSUMER_SECRET, | |
access_token = env.TWITTER_ACCESS_TOKEN_KEY, | |
access_token_secret = env.TWITTER_ACCESS_TOKEN_SECRET) | |
#Abstract minefeed so you can recall it if there's an error | |
def mineFeed(self, twitterID): | |
print("Fetching feed...") | |
try: | |
userFeed = self.twitAPI.user_timeline(user_id=str(int(twitterID)), exclude_replies="true", include_rts="false" ) | |
storeFeed(twitterID, userFeed) | |
except Exception as err: | |
if('88' in str(err)): | |
print("Mining Suspended: Reached Twitter rate limit") | |
print("Waiting 3 minutes then retrying...") | |
time.sleep(180) | |
self.mineFeed( twitterID) #Call function again after timeout | |
else: | |
print("ERROR: Something broke when fetching the feed") | |
print str(err) | |
else: | |
print("Fetch sucessful.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment