I'm trying to parse json data from the following website, and I'm getting the following error:
Error Type: <type 'exceptions.TypeError'>
Error Contents: unhashable type: 'list'
File "/....py", line 95, in <module>
['title']: post['title'],
TypeError: unhashable type: 'list'
-->End of Python script error report<--
My code is as follows, as you can see, I've tried to create a dict = but obviously I've not done it correctly. I understand the json data stuff needs to be added to a dictionary but I can't work out how to do this. Any help would be greatly appreciated.
def get_playable_podcast(soup):
"""
@param: parsed html page
"""
data = []
r = urllib.urlopen('https://thisiscriminal.com/wp-json/criminal/v1/episodes?posts=10000&page=1')
data = json.loads(r.read().decode('utf-8'))
my_dict = {'title': 'test1','episodeNumber': 'test2', 'audioSource': 'test3', 'image': 'test4', 'medium': 'test5'}
for post in data['posts']:
print post['title']
print post['episodeNumber']
print post['audioSource']
print post['image']['medium']
print post['content'] ASCII encoding error
item = {
['title']: post['title'],
['audioSource']: post['audioSource'],
['content']: desc,
['episodeNumber']: post['episodeNumber'],
['medium']: post['image']['medium']
}
data.append(item)
print data
print subjects
#subjects.append(item)
#print subjects