Skip to content

Instantly share code, notes, and snippets.

@neelindresh
Last active February 20, 2019 18:52
Show Gist options
  • Save neelindresh/73cdd149fa2daca6bde80e5a083de030 to your computer and use it in GitHub Desktop.
Save neelindresh/73cdd149fa2daca6bde80e5a083de030 to your computer and use it in GitHub Desktop.
Getting Twitter Data
import tweepy
from tweepy import Cursor,API
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler,Stream
import Credential
auth=OAuthHandler(Credential.CUSTOMER_KEY,Credential.CUSTOMER_SECRECT_KEY)
auth.set_access_token(Credential.ACCESS_TOKEN,Credential.ACCESS_SECRECT_TOKEN)
api=API(auth,wait_on_rate_limit=True)
for tweet in tweepy.Cursor(api.search,q="PulwamaAttack",lang='en',count=100,since='2019-02-14',tweet_mode="extended").items():
date=tweet._json['created_at']
print(date)
with open('tweetCur.json','ab') as file:
file.write(str(str(tweet._json)+'\n').encode('utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment