- Mastering Machine Learning on AWS
- Dr. Saket S.R. Mengle Maximo Gurmendez
- 125字
- 2021-06-24 14:23:15
Collecting the tweets
We will start by using the Twython library to access the Twitter API and collect a series of tweets, labeling them with the originating political party.
The details of the implementation can be found in our GitHub repository in the following Jupyter Notebook:
chapter2/collect_tweets.ipynb
We need to invoke the following method in the Twython library to save tweets from @GOP and @TheDemocrats into two text files, gop.txt and dems.txt:
twitter.get_user_timeline(screen_name='GOP', tweet_mode='extended', count=500)
Each file contains 200 tweets. The following are some excerpts from the dems.txt file:
- This cannot be who we are as a country. We need to find out what happened and ensure it never happens again.
- RT @AFLCIO: Scott Walker. Forever a national disgrace.