官术网_书友最值得收藏!

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.
主站蜘蛛池模板: 永丰县| 兴文县| 潜江市| 富顺县| 东明县| 馆陶县| 贵港市| 郸城县| 洪洞县| 应城市| 怀集县| 太保市| 佳木斯市| 城步| 丰县| 鲁山县| 嘉义市| 建宁县| 临泽县| 满洲里市| 郓城县| 衡阳市| 施秉县| 高陵县| 澎湖县| 霍城县| 民丰县| 葵青区| 绿春县| 资溪县| 阆中市| 西昌市| 大渡口区| 朝阳区| 右玉县| 新宾| 霍邱县| 荔波县| 深泽县| 三穗县| 龙岩市|