I am fetching tweets from a specific region, but i am getting very different result sets. First method by giving longitude and latitude within a given radius. These are the longitude and latitude within city (Lahore,PK) and draw 5km radius. 5km is a very small portion of this city. By this i fetched around 60,000 tweets of a single day.
Method1
import tweepy
consumer_key= ‘xxxxxxxxxxxxxx’
consumer_secret= ‘xxxxxxxxxxxxx’
access_token=‘xxxxxxxxxxxxxxx’
access_token_secret=‘xxxxxxxxxxxxxxxxxxxx’
api = tweepy.API(auth,wait_on_rate_limit = Truewait_on_rate_limit_notify= True)
public_tweets = tweepy.Cursor(api.search, count=100, geocode=“31.578871,74.305184,5km”,since=“2018-06-09”,show_user = True,tweet_mode=“extended”).items()
for tweet in public_tweets:
print(tweet.full_text)
Second Method, i used twitter geo search api, by querying Lahore, granularity=“city”. Now i am fetching tweets of whole city. but now i am getting 1200 tweets only of one day. I also fetched from past 7 days and get only 15,000 tweets. This is a very big difference that whole city is only giving me 1200 tweets and small portion of the same city is giving me more than 60,000 tweets. I also print the place id to verify that i am getting accurate polygons. These are the polygons ( 74.4493870, 31.4512220 74.4493870, 31.6124170 74.2675860, 31.6124170 74.2675860, 31.4512220) and i draw these on https://www.keene.edu/ to verify. and yes these are accurate polygons of Lahore city.
Method2
import tweepy
consumer_key= ‘xxxxxxxxxxxxxx’
consumer_secret= ‘xxxxxxxxxxxxx’
access_token=‘xxxxxxxxxxxxxxx’
access_token_secret=‘xxxxxxxxxxxxxxxxxxxx’
api = tweepy.API(auth,wait_on_rate_limit = Truewait_on_rate_limit_notify= True)
places = api.geo_search(query=“Lahore”, granularity=“city”)
for place in places:
print(“placeid:%s” % place)
public_tweets = tweepy.Cursor(api.search, count=100,q=“place:%s” % place.id,since=“2018-06-09”,show_user = True,tweet_mode=“extended”).items()
for tweet in public_tweets:
print(tweet.full_text)
Now first tell me why this is huge difference in result. I am using standard Api version. Second, tell me How these (api)s fetch tweets. because less then 1% tweets are geo-tagged and also not every user on there profile give exact city and country. Some users mention like Mars and Earth etc. So How these api work to fetch tweets in a specific region. either searching in a radius or by quering city/country. I studied twitter api docs and tweepy docs to study how these api work in background to collect tweets of specific region, but i do not found any helpful material.