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

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.
主站蜘蛛池模板: 荥阳市| 彰化县| 游戏| 洛川县| 宁国市| 赤水市| 新竹县| 武宁县| 嘉义县| 台州市| 利川市| 包头市| 建湖县| 兴安县| 汉中市| 天柱县| 梓潼县| 微山县| 英山县| 荔浦县| 烟台市| 驻马店市| 桑日县| 景谷| 靖边县| 麻江县| 安阳市| 金山区| 福海县| 渝中区| 花垣县| 霍林郭勒市| 五河县| 湟中县| 当阳市| 鄂尔多斯市| 八宿县| 南宫市| 西青区| 泸溪县| 永登县|