Twitter API と認証

Pythonによるデータインポート中級

Hugo Bowne-Anderson

Data Scientist at DataCamp

学習内容

  • Twitter API からデータをストリーミングする方法
  • キーワードで受信ツイートをフィルタリングする方法
  • API認証とOAuthについて

ch_3_1.003.png

Pythonによるデータインポート中級

学習内容

  • Twitter API からデータをストリーミングする方法
  • キーワードで受信ツイートをフィルタリングする方法
  • API認証とOAuthについて
  • Tweepy Python パッケージの使い方

ch_3_1.006.png

Pythonによるデータインポート中級

Twitter API へのアクセス

ch_3_1.008.png

Pythonによるデータインポート中級

Twitter API へのアクセス

ch_3_1.009.png

Pythonによるデータインポート中級

Twitter API へのアクセス

ch_3_1.011.png

Pythonによるデータインポート中級

Twitter API へのアクセス

ch_3_1.013.png

Pythonによるデータインポート中級

Twitterには複数のAPIがある

ch_3_1.015.png

Pythonによるデータインポート中級

Twitterには複数のAPIがある

ch_3_1.017.png

Pythonによるデータインポート中級

Twitterには複数のAPIがある

ch_3_1.018.png

Pythonによるデータインポート中級

Twitterには複数のAPIがある

ch_3_1.020.png

Pythonによるデータインポート中級

Twitterには複数のAPIがある

ch_3_1.022.png

Pythonによるデータインポート中級

ツイートはJSONとして返される

ch_3_1.024.png

Pythonによるデータインポート中級

ツイートはJSONとして返される

ch_3_1.026.png

Pythonによるデータインポート中級

Tweepy を使用するには: 認証

tweets.py

import tweepy, json

access_token = "..." access_token_secret = "..." consumer_key = "..." consumer_secret = "..."
Pythonによるデータインポート中級

Tweepy を使用するには: ツイートのストリーミング

tweets.py

# Create Streaming object
stream = tweepy.Stream(consumer_key, consumer_secret, 
                       access_token, access_token_secret)

# This line filters Twitter Streams to capture data by keywords: stream.filter(track=['apples', 'oranges'])
Pythonによるデータインポート中級

練習しましょう!

Pythonによるデータインポート中級

Preparing Video For Download...