我试图从Instagram API获取用户的图像,如下所示:
shop_recent_items, next_ = instagram_api.user_recent_media( user_id=obj.insta_user_id, count=33)这将返回图像和视频。 我甚至试过这个:
shop_recent_items, next_ = instagram_api.user_recent_media( user_id=obj.insta_user_id, type='image' count=33)我又得到了图像和视频类型的媒体。
我如何只获得图像?
I am trying to get only images of a user from Instagram API like this:
shop_recent_items, next_ = instagram_api.user_recent_media( user_id=obj.insta_user_id, count=33)this returns both images and videos. I tried even this:
shop_recent_items, next_ = instagram_api.user_recent_media( user_id=obj.insta_user_id, type='image' count=33)again I get both image and video type media.
How do I get only images?
最满意答案
查看官方文档 ,它说它可能会返回图像和视频类型的混合。 所以你不可能说你只想要图像。 相反,一旦您检索信息,提取图像。
因此,一旦获得JSON数据,使用for循环,您就可以找到所有图像。 示例代码:
for media in shop_recent_items: try: print media['images'] except KeyEror: continue如果您可以向我显示shop_recent_items确切响应和内容,我将相应地编辑此示例代码。
Looking at the official documentation, it says it may return a mix of both image and video types. So you cannot possibly say you only want images. Instead, once you retrieve the info, extract images.
So once you get the JSON data, using a for loop, you can find all the images. Sample code:
for media in shop_recent_items: try: print media['images'] except KeyEror: continueIf you could show me exact response and contents of shop_recent_items, I will edit this sample code accordingly.
更多推荐
发布评论