Home > database >  How to extract specific text from JSON response
How to extract specific text from JSON response

Time:08-25

I am using the Twitter API to source tweets, and am using their provided GitHub example. However, the tweets are given in a JSON format. How can I extract one part (specifically the text and tag) and place it into either a list, dataframe (most ideal option), dict etc?

    for response_line in response.iter_lines():
    if response_line:
        json_response = json.loads(response_line)
        tweets.append(json_response)

Upon viewing the 'tweets' list, the data uses the following format:

{'data': {'id': '1562362833374945281',
'text': 'Waiting            
  • Related