我在python-3.3中使用Instagram开发者API的用户端点从我跟踪的人中获取最近的媒体。
response = requests.get(URL).json()
test = response["data"]
return HttpResponse(test, "text/html")给我数据的内容..。在我对应的示例响应中。
然而,我似乎无法更深入地访问内容。例如,
response = requests.get(URL).json()
test = response["data"]
return HttpResponse(test[0], "text/html")给我下一个钥匙的列表:
"typecreated_timeuserattributionfilterusers_in_photocaptionlikestagslinkimagesiduser_has_likedcommentslocation“
同时:
response = requests.get(URL).json()
test = response["data"]
return HttpResponse(test["images"], "text/html")给出了一个例外:“列表索引必须是整数,而不是str”。
我也可以为每一个外观和类似的:
response = requests.get(URL).json()
test = response["data"]
for test in response["data"]:
for image in test["images"]:
HttpResponse(image["low_resolution"], "text/html")
return HttpResponse(test["images"], "text/html")etc,它将继续返回键名,直到像上面这样的点给出一个错误“字符串索引必须是整数”。
例如,如果我希望访问数据->(第一个块)->图像->低分辨率->url,那么我应该怎么做呢?
提前谢谢。
发布于 2016-04-15 02:41:23
我发现响应‘数据’图像‘url’会让你在json中获得低分辨率。
https://stackoverflow.com/questions/36509355
复制相似问题