ทำความเข้าใจ 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,
      ...  }
  • จำนวน retweet และ favorite
  • ภาษา
  • ตอบกลับทวีตใด
  • ตอบกลับผู้ใช้ใด
การวิเคราะห์ข้อมูลโซเชียลมีเดียด้วย Python

Child JSON objects

{
        "user": {
            "id": 661613,
            "name": "Alex Hanna, Data Witch",
            "screen_name": "alexhanna",
            "location": "Toronto, ON",
            ...
         }
}
การวิเคราะห์ข้อมูลโซเชียลมีเดียด้วย Python

สถานที่, retweet/quoted tweet และทวีตที่ยาวกว่า 140 ตัวอักษร

  • place และ coordinate
    • เก็บข้อมูล geolocation
  • extended_tweet
    • ทวีตที่ยาวกว่า 140 ตัวอักษร
  • retweeted_status และ quoted_status
    • เก็บข้อมูลทวีตทั้งหมดของ retweet และ quoted tweet
การวิเคราะห์ข้อมูลโซเชียลมีเดียด้วย Python

การเข้าถึง JSON

import json

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

tweet = json.loads(tweet_json)
tweet['text']
การวิเคราะห์ข้อมูลโซเชียลมีเดียด้วย Python

Child tweet JSON

tweet['user']['screen_name']

tweet['user']['name']
tweet['user']['created_at']
การวิเคราะห์ข้อมูลโซเชียลมีเดียด้วย Python

มาฝึกกันเถอะ!

การวิเคราะห์ข้อมูลโซเชียลมีเดียด้วย Python

Preparing Video For Download...