LoginSignup
2

More than 3 years have passed since last update.

posted at

updated at

Twythonを使って色々やってみる

twythonをインストール

$ pip install twython

OAuth 2設定

twythonをimportし、TwitterのAPI情報を設定

from twython import Twython

APP_KEY = 'YOUR_APP_KEY'
APP_SECRET = 'YOUR_APP_SECRET'

twitter = Twython(APP_KEY, APP_SECRET, oauth_version=2)
ACCESS_TOKEN = twitter.obtain_access_token()

twitter = Twython(APP_KEY, access_token=ACCESS_TOKEN)

Tweetをキーワードで抽出

twitter.search(q='xxx')

#人気順で表示する場合は↓等、色々カスタマイズできます(リファレンスtwitter developer参照)
#twitter.search(q='xxx', result_type='popular')

リファレンス

twython
twitter developer

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
2