Twitter
Python3
tweetid

Twitter の特定ユーザーのツイートを取得

特定ユーザーのツイートを取得する方法です。
API名は、user_timeline ですが、特定ユーザーのツイートを取得できます。

参考情報
GET statuses/user_timeline - ユーザータイムラインを取得する

get_tweet.py
#! /usr/bin/python3
# -*- coding: utf-8 -*-
#
#   get_tweet.py
#
#                       Dec/21/2017
# --------------------------------------------------------------------
import sys
import json
import oauth2 as oauth
#
from define_client import define_client_proc
# --------------------------------------------------------------------
# [8]:
def get_tweets_proc(client,user_id):
    nnx = 10
    url_base = "https://api.twitter.com/1.1/statuses/user_timeline.json?user_id="
    url = url_base + user_id + "&count=" + str(nnx)
    array_aa = []
    response, data = client.request(url)
    if response.status == 200:
        json_str = data.decode('utf-8')
#       print(json_str)
        array_aa = json.loads(json_str)
        sys.stderr.write("len(array_aa) = %d\n" % len(array_aa))
#
    else:
        sys.stderr.write("*** error *** get_ids_proc ***\n")
        sys.stderr.write("Error: %d\n" % response.status)
#
    return  array_aa
# --------------------------------------------------------------------
sys.stderr.write("*** 開始 ***\n")
#
user_id = "276219120"
#
client = define_client_proc()
#
array_aa = get_tweets_proc(client,user_id)
#
sys.stderr.write("len(array_aa) = %d\n" % len(array_aa))
#
for unit_aa in array_aa:
    print (unit_aa['created_at'])
    print (unit_aa['id'])
    print (unit_aa['text'])
#
sys.stderr.write("*** 終了 ***\n")
# --------------------------------------------------------------------
define_client.py
# -*- coding: utf-8 -*-
#
#   define_client.py
#
#                       Dec/21/2017
# --------------------------------------------------------------------
import sys
import oauth2 as oauth
#
# --------------------------------------------------------------------
# [2]:
def define_client_proc():
    CONSUMER_KEY = 'xxxxxxxxxxxxxxxxxxxxx'
    CONSUMER_SECRET = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
    ACCESS_KEY = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
    ACCESS_SECRET = 'ppppppppppppppppppppppppppppppppppppppppppppppp'
#
    consumer = oauth.Consumer(key=CONSUMER_KEY, secret=CONSUMER_SECRET)
    access_token = oauth.Token(key=ACCESS_KEY, secret=ACCESS_SECRET)
    client = oauth.Client(consumer, access_token)
#
    return client
# --------------------------------------------------------------------

Arch Linux でのライブラリーのインストール

sudo pip install oauth2