1 # Modify twitter3.py to produce a list of 1000 tweets about a topic of
4 # Note: I've changed it to search for "community data" instead of "data science."
8 from twitter_authentication import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET
11 auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
12 auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
14 api = tweepy.API(auth)
16 # 100 is the maximum number taht can be returned according to:
17 # https://dev.twitter.com/rest/reference/get/search/tweets
20 for page in tweepy.Cursor(api.search, "community data", count=100).pages():
21 counter = counter + len(page)
23 print(tweet.user.screen_name + "\t" + str(tweet.created_at) + "\t" + tweet.text)
24 # end this loop if we've gotten 1000
28 # This page suggests we can do one request every 5 seconds:
29 # https://dev.twitter.com/rest/reference/get/search/tweets