Last active
December 10, 2015 19:38
-
-
Save sonkm3/4482584 to your computer and use it in GitHub Desktop.
python: fetch tweets by tweepy's Cursor but this stops before it reaches the end..
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
# -*- coding: utf-8 -*- | |
import tweepy | |
consumer_token = '' | |
consumer_secret = '' | |
access_token = '' | |
access_secret = '' | |
def get_tweets(api, screen_name): | |
for tweet in tweepy.Cursor(api.user_timeline, screen_name = screen_name).items(): | |
yield tweet | |
def main(): | |
screen_name = sys.argv[1] | |
auth = tweepy.OAuthHandler(consumer_token, consumer_secret) | |
auth.set_access_token(access_token, access_secret) | |
api = tweepy.API(auth_handler=auth) | |
for tweet in get_tweets(api, screen_name): | |
print (tweet.id_str + u"\t" + tweet.text + u"\t" + str(tweet.created_at)).encode('utf-8') # print as utf-8 for redirection. | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment