I'm trying to get certain strings from a website but having difficulty. This is the array (blocking out certain values)
{
"ts": 1468156734285,
"inbox": "email",
"created": 302,
"expire_in": 86098,
"last_eml": 1468156432,
"emls": [{
"eml": "this is the email id",
"eml_hash": "email hash",
"eml_destroy_hash": "3319b480",
"subject": "Welcome to your new temporary inbox",
"from_address": "[email protected]",
"from_name": "welcome",
"status": "read",
"received": 302,
"size": 0
}]
}
In the 'emls' array, I'm trying to get 'eml' and 'eml_hash' as a python string. This is my code so far:
response = requests.get(url)
data = response.json()
print data
emal = data['emls']
eml_hash = data['eml_hash']
But it can't find these values
Traceback (most recent call last):
File "test.py", line 40, in <module>
emal= data['eml']
KeyError: 'eml' Thanks
print data? And are you this is the code you are running? in your codeemal = data['emls']but in the erroremal = data['eml']