In [2]:
import tweepy
from tweepy import OAuthHandler

customer_key = "***"
customer_secret = "***"
access_token = "***"
access_secret = "***"

auth = OAuthHandler(customer_key, customer_secret)
auth.set_access_token(access_token, access_secret)

api = tweepy.API(auth)
In [4]:
from pymongo import MongoClient
client = MongoClient()
db = client.twitterDb
posts = db.modiPosts
In [24]:
import json
tweets = api.search(q = "#modi", count = 100)
for tweet in tweets:
    posts.insert_one(tweet._json)
In [24]:
posts = db.tenKtweets
tweets = api.search(q = "place:b850c1bfd38f30e0", count = 500)
for tweet in tweets:
    posts.insert_one(tweet._json)
In [30]:
posts = db.commonwealth
tweets = api.search(q = "#kathua", count = 200)
for tweet in tweets:
    posts.insert_one(tweet._json)
In [31]:
posts = db.music
tweets = api.search(q = "#music", count = 200)
for tweet in tweets:
    posts.insert_one(tweet._json)
In [22]:
place = api.geo_search(query = "India", granularity = 'country')
print(place[0].id)
b850c1bfd38f30e0