python 解析 json

#coding=utf=8
import urllib,json

url ='https://api.douban.com/v2/book/user/62855846/collections'
read = urllib.urlopen(url).read()


j = 0
titles=[]
atls=[]
images=[]

a = json.loads(read)
leng = int(a['total'])

for i in range(leng):
    titles.append( a['collections'][j]['book']['title'])
    atls.append(a['collections'][j]['book']['alt'])
    images.append( a['collections'][j]['book']['images']['medium'])   
    j=j+1
    
print titles
print atls
print images

  

posted on 2014-08-16 12:03  小与  阅读(176)  评论(0)    收藏  举报

导航