Skip to content

Instantly share code, notes, and snippets.

@johnciacia
Last active December 21, 2015 20:29
Show Gist options
  • Save johnciacia/6361377 to your computer and use it in GitHub Desktop.
Save johnciacia/6361377 to your computer and use it in GitHub Desktop.
Twitter Sentiment Analysis

Install dependencies

pip install twitter
pip install -U textblob
curl https://raw.github.com/sloria/TextBlob/master/download_corpora.py | python
from text.blob import TextBlob
from twitter import *
t = Twitter(
auth=OAuth(
OAUTH_TOKEN,
OAUTH_SECRET,
CONSUMER_KEY,
CONSUMER_SECRET
))
tweets = t.search.tweets(q="#python")
for tweet in tweets['statuses']:
print tweet['text']
print TextBlob(tweet['text']).sentiment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment