Python 尝试在Instagram API中查找跟随者计数
我希望找到一个特定用户的追随者数量,就像您使用Instagram API控制台时得到的那样:Python 尝试在Instagram API中查找跟随者计数,python,json,instagram,Python,Json,Instagram,我希望找到一个特定用户的追随者数量,就像您使用Instagram API控制台时得到的那样: from instagram.client import InstagramAPI access_token = "Access Token" api = InstagramAPI(access_token=access_token) user_info = api.user(user_id) print user_info 当我搜索用户id时,我从API控制台得到了什么 { "meta":
from instagram.client import InstagramAPI
access_token = "Access Token"
api = InstagramAPI(access_token=access_token)
user_info = api.user(user_id)
print user_info
当我搜索用户id时,我从API控制台得到了什么
{
"meta": {
"code": 200
},
"data": {
"username": "IGname",
"bio": "Comments,
"website": "http://instagram,
"profile_picture": "picture",
"full_name": "IGRealname",
"counts": {
"media": Number1,
"followed_by": Number2,
"follows": Number3
},
"id": "IGUserID"
}
我希望获得用户名、follows和要输出到python的字段
我得到的只是用户名,就是这样 当您调用用户信息时,它将返回给您。终点是: 所需的数据位于“计数”数组中 但是,在您的示例中,用户可能是私有的。当它是私密的时候,你不能得到其他的媒体。响应将有400个标题(错误请求),正文将是:
{"meta":
{"error_type":"APINotAllowedError",
"code":400,"error_message":"you cannot view this resource"
}
}
如果您愿意,请在此处注释用户id,以便我们再次检查。您可以使用此选项:
user_followers, next_ = api.user_followed_by()
while next_:
more_user_followers, next_ = api.user_followed_by(with_next_url=next_) #this will get you all your followers
user_followers.extend(more_user_followers)
len(user_followers) #this is the numbers of followers you have
它位于计数数组中。在API控制台中,我可以获得我想要的所有信息,但是我不知道如何通过Python访问相同的信息。这正是我想要的。如果我一开始不清楚,很抱歉。好的。。我还没有练习python。。我帮不了你。很抱歉