Last active
September 26, 2016 18:38
-
-
Save thearchduke/e6dc73220a6c249840377ce57cd3b358 to your computer and use it in GitHub Desktop.
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
try: | |
import cPickle as pickle | |
except: | |
import pickle | |
from twitter import * | |
import datetime | |
token = '' | |
token_key = '' | |
con_key = '' | |
con_secret = '' | |
twit = Twitter(auth=OAuth(token, token_key, con_key, con_secret)) | |
limits = twit.application.rate_limit_status() | |
n = limits['resources']['statuses']['/statuses/user_timeline']['remaining'] | |
all_tweets = twit.statuses.user_timeline(screen_name="Johngcole", count=200, include_retweets=False) | |
n -= 1 | |
last_id = all_tweets[-1]['id'] | |
while len(all_tweets) < 3200: | |
if n == 1: | |
break | |
more_tweets = twit.statuses.user_timeline(screen_name="Johngcole", count=200, max_id=last_id, include_retweets=False) | |
all_tweets += more_tweets | |
last_id = all_tweets[-1]['id'] | |
# if you want to watch your progress: | |
print n, len(all_tweets) | |
n -= 1 | |
# dump or do whatever with your all_tweets obj | |
pickle.dump(all_tweets, open('tweets_no_retweets.p', 'wb')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment