ボールを蹴りたいシステムエンジニア

ボール蹴りが大好きなシステムエンジニア、ボールを蹴る時間確保の為に時間がある時には勉強する。

python3でTwitter APIからデータを取得

環境

CentOS6
python3.5

手順

Twitter API Keyを取得する。

Twitterアカウント作成後、以下にアクセス。
※アカウント登録には電話番号のひも付けが必要
https://apps.twitter.com/

「Create New App」をクリック

web siteには「http://127.0.0.1」を入力しても大丈夫だった。

登録後、「Keys and Access Tokens」タブでAPI Keyが確認できる。


requests-oauthlibインストール

pip install requests-oauthlib

API Keyの管理は設定ファイルで管理する。

twitter_api.ini

[twtter_api]
consumer_key=*****
consumer_key_secret=*****
access_token=*****
access_token_secret=*****

下記サイトを参考にAPI Key管理方法だけ変更して動いた。

http://umanotsubuyaki.blog.fc2.com/blog-entry-15.html?sp