Twitter JSON begrijpen

Socialmediagegevens analyseren in Python

Alex Hanna

Computational Social Scientist

Inhoud van 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,
      ...  }
  • Aantal retweets, favorieten
  • Taal
  • Antwoord op welke tweet
  • Antwoord aan welke gebruiker
Socialmediagegevens analyseren in Python

Geneste JSON-objecten

{
        "user": {
            "id": 661613,
            "name": "Alex Hanna, Data Witch",
            "screen_name": "alexhanna",
            "location": "Toronto, ON",
            ...
         }
}
Socialmediagegevens analyseren in Python

Locaties, retweets/geciteerde tweets en 140+ tweets

  • place en coordinate
    • bevatten geolocatie
  • extended_tweet
    • tweets met meer dan 140 tekens
  • retweeted_status en quoted_status
    • bevatten alle tweetinfo van retweets en geciteerde tweets
Socialmediagegevens analyseren in Python

JSON benaderen

import json

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

tweet = json.loads(tweet_json)
tweet['text']
Socialmediagegevens analyseren in Python

Geneste tweet-JSON

tweet['user']['screen_name']

tweet['user']['name']
tweet['user']['created_at']
Socialmediagegevens analyseren in Python

Laten we oefenen!

Socialmediagegevens analyseren in Python

Preparing Video For Download...