LoginSignup
45
34

More than 5 years have passed since last update.

Tweepyのstatusリストで何が取れるのかわからなかったので、取り出してみた

Last updated at Posted at 2016-08-02

前書き

pythonでTwitterApiを使うためのライブラリを使っていて、

# Timelineの先頭のツイートを取得
status = api.home_timeline()[0].text

なんてやって値を取っていたわけなんですけど、text以外の値も欲しいなと思って、調べてリストにしたのでメモがてら貼っておきます。
* Document見ながら作ったわけじゃないので、わからなければ、Document読んで下さい。

開発環境

機種名 : MacBook Pro
OS : Yosemite 10.10.5
プロセッサ名 : Intel Core i5 2.6 GHz
メモリ : 16 GB
グラフィック : Intel Iris 1536MB

python 2.7.12
Tweepy 3.5.0

本題

えいっ

status = api.home_timeline()[0]
print dir(status)
parameter 概要
__class__ クラスオブジェクト <class 'tweepy.models.Status'>
__delattr__ delattrオブジェクト <method-wrapper '__delattr__' of Status object at 0x1084881d0>
__dict__ jsonデータ
__doc__ None
__eq__ jsonデータ
__format__ formatオブジェクト <built-in method __format__ of Status object at 0x101a1efd0>
__getattribute__ getattributeオブジェクト <method-wrapper '__getattribute__' of Status object at 0x101a1efd0>
__getstate__
__hash__ ハッシュオブジェクト <method-wrapper '__hash__' of Status object at 0x10c0b51d0>
__init__
__module__ モジュール tweepy.models
__ne__ neオブジェクト
__new__ newオブジェクト <built-in method __new__ of type object at 0x10ab01ab0>
__reduce__ リデュースオブジェクト <built-in method __reduce__ of Status object at 0x10bb5df50>
__reduce_ex__ リデュースオブジェクト(拡張) <built-in method __reduce_ex__ of Status object at 0x10bb5df50>
__repr__ reprオブジェクト
__setattr__ setattrオブジェクト <method-wrapper '__setattr__' of Status object at 0x106543150>
__sizeof__ sizeofオブジェクト <built-in method __sizeof__ of Status object at 0x106543150>
__str__ strオブジェクト <method-wrapper '__str__' of Status object at 0x106543150>
__subclasshook__ サブクラスフックオブジェクト <built-in method __subclasshook__ of type object at 0x7f9c81534cc0>
__weakref__ 弱い...リファレンス? None
_api API <tweepy.api.API object at 0x106222190>
_json json形式にまとまったデータ
author
contributors None
coordinates None
created_at 作られた時間 2016-08-02 10:00:00
destroy
entities {u'symbols': [], u'user_mentions': [], u'hashtags': [], u'urls': []}
extended_entities
favorite
favorite_count ラブされた数 0
favorited ラブをしたかどうか False
geo None
id ツイートの識別ID 123456789012345678
id_str ツイートの識別ID(文字列?) 123456789012345678
in_reply_to_screen_name None
in_reply_to_status_id None
in_reply_to_status_id_str None
in_reply_to_user_id None
in_reply_to_user_id_str None
is_quote_status 引用した(された?)かどうか False
lang 言語 ja
parse <bound method type.parse of <class 'tweepy.models.Status'>>
parse_list <bound method type.parse_list of <class 'tweepy.models.Status'>>
place 位置情報 None
possibly_sensitive
possibly_sensitive_appealable
retweet
retweet_count リツイート数 0
retweeted リツイートをしたかどうか False
retweeted_status
retweets
source ツイッタークライアント Twitter for iPhone
source_url ツイッタークライアントのURL http://twitter.com/download/iphone
text ツイート内容 お腹空いた、帰りたい
truncated 切り詰められた? False
user

感想

穴埋めできる方は、教えてもらえたら助かります。
説明間違ってるとかあっても押して下さい。

でかい、なんとかオブジェクトはとりあえずdir()すればいいと思うよ。

おまけ

他意はありませんよ?

#ユーザー名
print status.user.name
#ユーザーID
print status.user.screen_name
#鍵垢かどうか
print status.user.protected
#住んでるところ
print status.user.location

関連URL

Tweepy Documentation
http://docs.tweepy.org/en/v3.5.0/

45
34
2

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
  3. You can use dark theme
What you can do with signing up
45
34