Twitter の JSON を理解する

Python でのソーシャルメディアデータ分析

Alex Hanna

Computational Social Scientist

Twitter JSON の中身

{  "created_at": "Thu Apr 19 14:25:04 +0000 2018",
   "id": 986973961295720449,
   "id_str": "986973961295720449",
   "text": "Writing out the script of my @DataCamp class 
            and I can't help but mentally read it back to myself in 
            @hugobowne's voice.",    
   "retweet_count": 0,
   "favorite_count": 1,
      ...  }
  • リツイート数、お気に入り数
  • 言語
  • どのツイートへの返信か
  • どのユーザーへの返信か
Python でのソーシャルメディアデータ分析

子 JSON オブジェクト

{
        "user": {
            "id": 661613,
            "name": "Alex Hanna, Data Witch",
            "screen_name": "alexhanna",
            "location": "Toronto, ON",
            ...
         }
}
Python でのソーシャルメディアデータ分析

位置情報、リツイート/引用ツイート、140 文字超のツイート

  • place と coordinate
    • 位置情報を含む
  • extended_tweet
    • 140 文字を超えるツイート
  • retweeted_status と quoted_status
    • リツイートや引用ツイートのすべてのツイート情報を含む
Python でのソーシャルメディアデータ分析

JSON へのアクセス

import json

tweet_json = open('tweet-example.json', 'r').read()

tweet = json.loads(tweet_json)
tweet['text']
Python でのソーシャルメディアデータ分析

子ツイート JSON

tweet['user']['screen_name']

tweet['user']['name']
tweet['user']['created_at']
Python でのソーシャルメディアデータ分析

練習しましょう!

Python でのソーシャルメディアデータ分析

Preparing Video For Download...