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자 초과 트윗

  • placecoordinate
    • 지리적 위치 정보 포함
  • extended_tweet
    • 140자 초과 트윗
  • retweeted_statusquoted_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...