-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtwitterAPI.py
More file actions
26 lines (19 loc) · 805 Bytes
/
twitterAPI.py
File metadata and controls
26 lines (19 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import tweepy #Library for accessing Twitter API
from textblob import TextBlob #Library for Text Processing
#Setting up API credentials
#The credentials can be obtained by setting up your account at https://apps.twitter.com/
consumer_key=#insert consumer key here!
consumer_secret=#insert consumer secret here!
access_token=#insert access token here!
access_token_secret=#insert access token secret here
#Twitter API authentication
auth=tweepy.OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api=tweepy.API(auth) #API instance
#Printing random tweets and using them for some purpose!
public_tweets=api.search('#Demonetisation')
for tweet in public_tweets:
text=tweet.text
analysis=TextBlob(text)
print(text)
print(analysis.sentiment)