1 # Do "static" (i.e., not using the streaming API) geolocation search
2 # using code like this: d = api.search(geocode='37.781157,-122.398720,1mi')
6 from twitter_authentication import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET
9 auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
10 auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
12 api = tweepy.API(auth)
14 # 100 is the maximum number taht can be returned according to:
15 # https://dev.twitter.com/rest/reference/get/search/tweets
18 for page in tweepy.Cursor(api.search, "party", geocode='37.781157,-122.398720,1mi', count=100).pages():
19 counter = counter + len(page)
21 print(tweet.user.screen_name + "\t" + str(tweet.created_at) + "\t" + tweet.text)
22 # end this loop if we've gotten 1000
26 # This page suggests we can do one request every 5 seconds:
27 # https://dev.twitter.com/rest/reference/get/search/tweets