Entendendo o JSON do Twitter

Analisando dados de mídias sociais em Python

Alex Hanna

Computational Social Scientist

Conteúdo do JSON do Twitter

{  "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,
      ...  }
  • Quantos retweets, favoritos
  • Idioma
  • Em resposta a qual tweet
  • Em resposta a qual usuário
Analisando dados de mídias sociais em Python

Objetos JSON filhos

{
        "user": {
            "id": 661613,
            "name": "Alex Hanna, Data Witch",
            "screen_name": "alexhanna",
            "location": "Toronto, ON",
            ...
         }
}
Analisando dados de mídias sociais em Python

Locais, retweets/tweets citados e tweets 140+

  • place e coordinate
    • contêm geolocalização
  • extended_tweet
    • tweets com mais de 140 caracteres
  • retweeted_status e quoted_status
    • contêm todas as informações de retweets e tweets citados
Analisando dados de mídias sociais em Python

Acessando JSON

import json

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

tweet = json.loads(tweet_json)
tweet['text']
Analisando dados de mídias sociais em Python

JSON de tweet filho

tweet['user']['screen_name']

tweet['user']['name']
tweet['user']['created_at']
Analisando dados de mídias sociais em Python

Vamos praticar!

Analisando dados de mídias sociais em Python

Preparing Video For Download...