在我的一个脚本中获得了以下代码:
#
# url is defined above.
#
jsonurl = urlopen(url)
#
# While trying to debug, I put this in:
#
print jsonurl
#
# Was hoping text would contain the actual json crap from the URL, but seems not...
#
text = json.loads(jsonurl)
print text
我想要做的是获取{{.....etc.....}}在Firefox中将其加载到脚本中时在URL上看到的内容,以便我可以解析出一个值。我已经用Google搜索了很多,但是关于如何{{...}}从URL 实际获取内容.json到Python脚本中的对象中,我还没有找到一个好的答案。
json.loads消耗一列使用(这就是为什么.read()需要,使用json.load(response)来代替。