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

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.
主站蜘蛛池模板: 深泽县| 龙门县| 玉龙| 青岛市| 遵义市| 积石山| 灌南县| 云梦县| 建阳市| 怀集县| 宜川县| 广宗县| 唐山市| 万荣县| 玉山县| 中牟县| 汉源县| 文昌市| 贵定县| 前郭尔| 延安市| 新竹市| 文安县| 吴桥县| 台安县| 江阴市| 长子县| 都安| 鄂伦春自治旗| 新田县| 浠水县| 锡林浩特市| 玛沁县| 确山县| 巨野县| 灵川县| 满洲里市| 信阳市| 万山特区| 东台市| 广河县|