Simple way to get tweets and visualizing them into a wordcloud.
pip install git+git://github.com/axelbellec/twitter-timeline-wordcloud.git
Install requirements :
git clone http://github.com/axelbellec/twitter-timeline-wordcloud.git twc
python setup.py install
You have to create a keys.py
file containing Twitter API credentials :
CONSUMER_KEY = os.environ.get('CONSUMER_KEY')
CONSUMER_SECRET = os.environ.get('CONSUMER_SECRET')
ACCESS_TOKEN = os.environ.get('ACCESS_TOKEN')
ACCESS_TOKEN_SECRET = os.environ.get('ACCESS_TOKEN_SECRET')
Just follow these 3 steps : - Getting tweets - Cleaning them - Enjoying!
import tweetwordcloud as twc
import keys
# Get tweets posted by @OpenBikes_
tweets = ' '.join(twc.get_user_tweets(keys, user='OpenBikes_', nb=1000))
# Clean tweets
cleaned_tweets = twc.clean_tweets(tweets)
# Compute TagCloud
twc.wordcloud(data=cleaned_tweets, stopwords=twc.get_stopwords('french'),
mask='extras/twitter_mask.png', fontpath='extras/quartzo.ttf')