My request only returns twenty or so hits. Notice I set the radius to be 5000km which is ridiculous, that’s because I used 50 first but got too few hits, so I increased it. But even at 5000km, I’m still getting the same few results. I’m using Python 3.5
.
Here is the code:
import tweepy
consumer_key = 'xxxxx'
consumer_secret = 'xxxxxxxxx'
access_token = 'xxxxxxx'
access_token_secret = 'xxxxxxxxxxxxxxx'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
results = api.search(q="Global Warming",geocode="40.7142700,-74.0059,5000km",count=100)
for result in results:
print (result.text.encode('utf-8'))
2
Answers
Twitter limits how far back in the past you can search to about one week. You have reached that limit. You can see this for yourself if you inspect the
created_at
field of the last tweet returned.You are probably missing on tweets which:
When searching on tweets with the
geocode
field, theAPI
will first search for tweets with geolocation specified, otherwise it will use the location from the user profile.From the
Search API
onGeolocalization
:From the
search/tweets
doc: