仮想サーファーの波乗り

仮想サーファーの日常

プログラミング・エンジニアのスキルアップ・ブログ運営などに関してよく書く雑記ブログ

➡ Udemyで8/27(木)まで割引セール開催中! 1,200円〜で普段の90%以上OFF!

Tweepyで取得できるStatusの中身(つぶやき)データ一覧


TweepyでStatusオブジェクト(つぶやきデータ)が持っている値を毎回ググるのがめんどくさかったので書いておきます。

Tweepyで取得できる「Status」はつぶやきデータのことで、Statusオブジェクトはつぶやき情報、つぶやきをしたユーザーの情報などを持っているものです。

▼Statusオブジェクトの持っている値一覧

Status(_api=<tweepy.api.API object at 0xxx04f9xxx>,
 _json={'created_at': 'Thu Apr 12 13:50:14 +0000 2018',
 'id': 984428483374804992,
 'id_str': '984428483374804992',
 'text': '&gt; WeChatミニプログラれてから1年が過ぎ、100万人の開発者を対象とした58万のプログラムがあります。\n\nWeChatがiOS/Androidの代替になる未来もあるのかな\n\nhttps://t.co/zUDoVMPXwJ',
 'truncated': False,
 'entities': {'hashtag': [{'url': 'https://t.co/zUDoVMPXwJ',
 'expanded_url': 'http://36kr.com/p/5128731.html?ktm_source=feed',
 'display_url': '36kr.com/p/5128731.html…',
 'indices': [98, 121]}]},
 'source': '<a href="http://twitter.com" rel="nofollow">Twitter Web Client</a>',
 '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,
 'in_reply_to_screen_name': None,
 'user': {'id': 952004195497816064,
 'id_str': '952004195497816064',
 'name': '仮想サーファー@webエンジニア',
 'screen_name': 'virtual_techX',
 'location': '波場',
 'description': エンジニア。ブロックチェーン、仮想通貨、AR、プログラミング、ブログ、中国情勢などに関してよくつぶやきます。',
 'url': 'https://t.co/9PtfVJR3I3',
 'entities': {'url': {'urls': [{'url': 'https://t.co/9er.com/',
 'display_url': 'virtual-surfer.com',
 'indices': [0, 23]}]},
 'description': {'urls': []}},
 'protected': False,
 'followers_count': 1520,
 'friends_count': 232,
 'listed_count': 7,
 'created_at': 'Sat Jan 13 02:27:42 +0000 2018',
 'favourites_count': 130,
 'utc_offset': None,
 'time_zone': None,
 'geo_enabled': False,
 'verified': False,
 'statuses_count': 774,
 'lang': 'ja',
 'contributors_enabled': False,
 'is_translator': False,
 'is_translation_enabled': False,
 'profile_background_color': '000000',
 'profile_background_image_url': 'http://abs.twimg.com/images/themes/theme1/bg.png',
 'profile_background_image_url_https': 'https://abs.twimg.com/images/themes/theme1/bg.png',
 'profile_background_tile': False,
 'profile_image_url': 'http://pbs.twimg.com/profile_images/952006494731431936/oERsC_dh_normal.jpg',
 'profile_image_url_https': 'https://pbs.twimg.com/profile_images/952006494731431936/oERsC_dh_normal.jpg',
 'profile_link_color': '1B95E0',
 'profile_sidebar_border_color': '000000',
 'profile_sidebar_fill_color': '000000',
 'profile_text_color': '000000',
 'profile_use_background_image': False,
 'has_extended_profile': False,
 'default_profile': False,
 'default_profile_image': False,
 'following': False,
 'follow_request_sent': False,
 'notifications': False,
 'translator_type': 'none'},
 'geo': None,
 'coordinates': None,
 'place': None,
 'contributors': None,
 'is_quote_status': False,
 'retweet_count': 0,
 'favorite_count': 1,
 'favorited': False,
 'retweeted': False,
 'possibly_sensitive': True,
 'lang': 'ja'},
 created_at=datetime.datetime(2018, 4, 12, 13, 50, 14),
 id=984428483374804992,
 id_str='984428483374804992',
 text='&gt; WeChatミニプログラムが開始されてから1年が過ぎ、100万人の開発者を対象とした58万のプログラムがあります。\n\nWeChatiOS/Androidの代替に=False,
 entities={'hashtags': [],
 'symbols': [],
 'user_mentions': [],
 'urls': [{'url': 'https://t.co/zUDoVMPXwJ',
 'expanded_url': 'http://36kr.com/p/5128731.html?ktm_source=feed',
 'display_url': '36kr.com/p/5128731.html…',
 'indices': [98, 121]}]},
 source='Twitter Web Client',
 source_url='http://twitter.com',
 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,
 in_reply_to_screen_name=None,
 author=User(_api=<tweepy.api.API object at 0x1104f90b8>,
 _json={'id': 952004195497816064,
 'id_str': '952004195497816064',
 'name': '仮想サーファー@webエンジニア',
 'screen_name': 'virtual_techX',
 'location': '波場',
 'description': '文系出身webエンジニア。ブロックチェーン、仮想通貨、AR、プログラミング、ブログ、中国情勢などに関してps://t.co/9PtfVJR3I3',
 'entities': {'url': {'urls': [{'url': 'https://t.co/9PtfVJR3I3',
 'expanded_url': 'http://www.virtual-surfer.com/',
 'display_url': 'virtual-surfer.com',
 'indices': [0, 23]}]},
 'description': {'urls': []}},
 'protected': False,
 'followers_count': 1520,
 'friends_count': 232,
 'listed_count': 7,
 'created_at': 'Sat Jan 13 02:27:42 +0000 2018',
 'favourites_count': 130,
 'utc_offset': None,
 'time_zone': None,
 'geo_enabled': False,
 'verified': False,
 'statuses_count': 774,
 'lang': 'ja',
 'contributors_enabled': False,
 'is_translator': False,
 'is_translation_enabled': False,
 'profile_background_color': '000000',
 'profile_background_image_url': 'http://abs.twimg.com/images/themes/theme1/bg.png',
 'profile_background_image_url_https': 'https://abs.twimg.com/images/themes/theme1/bg.png',
 'profile_background_tile': False,
 'profile_image_url': 'http://pbs.twimg.com/profile_images/952006494731431936/oERsC_dh_normal.jpg',
 'profile_image_url_https': 'https://pbs.twimg.com/profile_images/952006494731431936/oERsC_dh_normal.jpg',
 'profile_link_color': '1B95E0',
 'profile_sidebar_border_color': '000000',
 'profile_sidebar_fill_color': '000000',
 'profile_text_color': '000000',
 'profile_use_background_image': False,
 'has_extended_profile': False,
 'default_profile': False,
 'default_profile_image': False,
 'following': False,
 'follow_request_sent': False,
 'notifications': False,
 'translator_type': 'none'},
 id=952004195497816064,
 id_str='952004195497816064',
 name='仮想サーファー@webエンジニア',
 screen_name='virtual_techX',
 location='波場',
 description='ロックチェーン、仮想通貨、AR、プログラミング、ブログ、中国情勢などに関してよくつぶやきます。',
 url='https://t.co/9PtfVJR3I3',
 entities={'url': {'urls': [{'url': 'https://t.co/9PtfVJR3I3',
 'expandesplay_url': 'virtual-surfer.com',
 'indices': [0, 23]}]},
 'description': {'urls': []}},
 protected=False,
 followers_count=1520,
 friends_count=232,
 listed_count=7,
 created_at=datetime.datetime(2018, 1, 13, 2, 27, 42),
 favourites_count=130,
 utc_offset=None,
 time_zone=None,
 geo_enabled=False,
 verified=False,
 statuses_count=774,
 lang='ja',
 contributors_enabled=False,
 is_translator=False,
 is_translation_enabled=False,
 profile_background_color='000000',
 profile_background_image_url='http://abs.twimg.com/images/themes/theme1/bg.png',
 profile_background_image_url_https='https://abs.twimg.com/images/themes/theme1/bg.png',
 profile_background_tile=False,
 profile_image_url='http://pbs.twimg.com/profile_images/952006494731431936/oERsC_dh_normal.jpg',
 profile_image_url_https='https://pbs.twimg.com/profile_images/952006494731431936/oERsC_dh_normal.jpg',
 profile_link_color='1B95E0',
 profile_sidebar_border_color='000000',
 profile_sidebar_fill_color='000000',
 profile_text_color='000000',
 profile_use_background_image=False,
 has_extended_profile=False,
 default_profile=False,
 default_profile_image=False,
 following=False,
 follow_request_sent=False,
 notifications=False,
 translator_type='none'),
 user=User(_api=<tweepy.api.API object at 0x1104f90b8>,
 _json={'id': 952004195497816064,
 'id_str': '952004195497816064',
 'name': '仮想サーファー@webエンジニア',
 'screen_name': 'virtualcation': '波場',
 'description': '文系出身webエンジニア。ブロックチェーン、仮想通貨、AR、プログラミング、ブログ、中国情勢などに関してよくつぶやきます。',
 'url': 'https://t.co/9PtfVJR3I3',
 'entitiesxpanded_url': 'http://www.virtual-surfer.com/',
 'display_url': 'virtual-surfer.com',
 'indices': [0, 23]}]},
 'description': {'urls': []}},
 'protected': False,
 'followers_count': 1520,
 'friends_count': 232,
 'listed_count': 7,
 'created_at': 'Sat Jan 13 02:27:42 +0000 2018',
 'favourites_count': 130,
 'utc_offset': None,
 'time_zone': None,
 'geo_enabled': False,
 'verified': False,
 'statuses_count': 774,
 'lang': 'ja',
 'contributors_enabled': False,
 'is_translator': False,
 'is_translation_enabled': False,
 'profile_background_color': '000000',
 'profile_background_image_url': 'http://abs.twimg.com/images/themes/theme1/bg.png',
 'profile_background_image_url_https': 'https://abs.twimg.com/images/themes/theme1/bg.png',
 'profile_background_tile': False,
 'profile_image_url': 'http://pbs.twimg.com/profile_images/952006494731431936/oERsC_dh_normal.jpg',
 'profile_image_url_https': 'https://pbs.twimg.com/profile_images/952006494731431936/oERsC_dh_normal.jpg',
 'profile_link_color': '1B95E0',
 'profile_sidebar_border_color': '000000',
 'profile_sidebar_fill_color': '000000',
 'profile_text_color': '000000',
 'profile_use_background_image': False,
 'has_extended_profile': False,
 'default_profile': False,
 'default_profile_image': False,
 'following': False,
 'follow_request_sent': False,
 'notifications': False,
 'translator_type': 'none'},
 id=952004195497816064,
 id_str='952004195497816064',
 name='仮想サーファー@webエンジニア',
 screen_name='virtual_techX',
 location='波場',
 description='文系出身webエンジニア。ブロックチェーン、仮想通貨、AR、プログラミング、ブログ、中国情勢などies={'url': {'urls': [{'url': 'https://t.co/9PtfVJR3I3',
 'expanded_url': 'http://www.virtual-surfer.com/',
 'display_url': 'virtual-surfer.com',
 'indices': [0, 23]}]},
 'description': {'urls': []}},
 protected=False,
 followers_count=1520,
 friends_count=232,
 listed_count=7,
 created_at=datetime.datetime(2018, 1, 13, 2, 27, 42),
 favourites_count=130,
 utc_offset=None,
 time_zone=None,
 geo_enabled=False,
 verified=False,
 statuses_count=774,
 lang='ja',
 contributors_enabled=False,
 is_translator=False,
 is_translation_enabled=False,
 profile_background_color='000000',
 profile_background_image_url='http://abs.twimg.com/images/themes/theme1/bg.png',
 profile_background_image_url_https='https://abs.twimg.com/images/themes/theme1/bg.png',
 profile_background_tile=False,
 profile_image_url='http://pbs.twimg.com/profile_images/952006494731431936/oERsC_dh_normal.jpg',
 profile_image_url_https='https://pbs.twimg.com/profile_images/952006494731431936/oERsC_dh_normal.jpg',
 profile_link_color='1B95E0',
 profile_sidebar_border_color='000000',
 profile_sidebar_fill_color='000000',
 profile_text_color='000000',
 profile_use_background_image=False,
 has_extended_profile=False,
 default_profile=False,
 default_profile_image=False,
 following=False,
 follow_request_sent=False,
 notifications=False,
 translator_type='none'),
 geo=None,
 coordinates=None,
 place=None,
 contributors=None,
 is_quote_status=False,
 retweet_count=0,
 favorite_count=1,
 favorited=False,
 retweeted=False,
 possibly_sensitive=True,
 lang='ja')


以下のように、statusにキーの値を指定することで、各値を取得することができます。(以下の例では、statusオブジェクトの中のtextの値をコンソールに出力しています。)

$ print(status.text)

WeChatミニプログラれてから1年が過ぎ、100万人の開発者を対象とした58万のプログラムがあります。\n\nWeChatがiOS/Androidの代替になる未来もあるのかな\n\nhttps://t.co/zUDoVMPXwJ


これだけのデータが1回の APIアクセスで取得できるのは嬉しい。