我试图解析JSON数据,但它没有工作,JSON解析器返回一个强大的不是字典! 这里的代码:蟒蛇无法解析JSON字符串
import urllib2
from BeautifulSoup import BeautifulSoup
import json
html = urllib2.urlopen("http://www.imdb.com//name/nm0425005/mediaviewer/rm244453632?ref_=nmmi_mi_all_sf_49").read()
soup = BeautifulSoup(html)
script = soup.find('script', {'id': 'imageJson'})
json_data = ''.join(map(str, script.contents))
json_data = json.dumps(json_data.strip(' \t\n\r'))
data = json.loads(json_data)
print data['mediaViewerModel']
是的,我打印json数据之前,它传递给json模块,但它看起来好吧 – Tyranitar