使用 Scrapy 或 Instagram 访问 Instagram 用户的所有关注者的用户名 Python API

Accessing the username of all the followers of a user in Instagram using Scrapy or Instagram Python API

如何获取 instagram 用户的每个关注者的用户名?在 json 中,我只能访问关注者的数量。 这是我正在使用的 json 处理的 URL:

"https://www.instagram.com/buzzfeed/?__a=1"
pprint(json_response["user"]["followed_by"]["count"])

这里是pprint(json_response["user"])

的开头
    {u'biography': u"Hi, we're:q
 BuzzFeed dot com the website. Download our app:",
     u'blocked_by_viewer': False,
     u'connected_fb_page': None,
     u'country_block': False,
     u'external_url': u'http://bzfd.it/2cpjV5B',
     u'external_url_linkshimmed': u'http://l.instagram.com/?e=ATN_0_BAWjtGnChrZAtmnHUKqbPDjr3JcppPl3dQc7xbokFd56UvRHua36v9XsY&u=http%3A%2F%2Fbzfd.it%2F2cpjV5B',
     u'followed_by': {u'count': 2527289},
     u'followed_by_viewer': False,
     u'follows': {u'count': 127},
     u'follows_viewer': False,
     u'full_name': u'BuzzFeed',
     u'has_blocked_viewer': False,
     u'has_requested_viewer': False,
     u'id': u'1538653985',
     u'is_private': False,
     u'is_verified': True,
     u'media': {u'count': 2175,
                u'nodes': [{u'__typename': u'GraphVideo',
                            u'caption': u'me when I finally get paid',
                            u'code': u'BRJs_2Zj143',
                            u'comments': {u'count': 1330},
                            u'comments_disabled': False,
                            u'date': 1488491778,
                            u'dimensions': {u'height': 640, u'width': 640},

我可以看到 u'follows_viewer': False 但这是 public 帐户,我可以从其 instagram 帐户看到 buzzfeed 的关注者。强烈建议任何想法。

更新: 我通过使用 Instagram API 尝试了另一种方法,我得到了 None,不知道出了什么问题:

print(api.user_followed_by(user_id=53112486))
([], None)
print(api.user_follows(user_id=53112486))
([], None)

我按照这种方法获取访问令牌,是不是错了?

https://api.instagram.com/oauth/authorize/?client_id=YOUR-CLIENT-ID&redirect_uri=YOUR-REDIRECT-URI&response_type=code&scope=basic+comments+follower_list+likes+relationships+public_content

我用 http://localhost:8515/oauth_callback 作为我的 redirect_uri

它问我这个:

这是我授权的!

也就是说,我可以得到我自己帐户的计数(53112486 是我的user_id):

info = api.user(user_id=53112486)
print(info.counts)

此外,当我尝试

https://api.instagram.com/v1/users/self/followed-by?access_token=MINE

我得到了以下信息!

{"pagination": {}, "meta": {"code": 200}, "data": []}

这两个return ([], None):

 50         for page in api.user_followed_by( as_generator=True):
 51             print(str(page))
 52 
 53         print(api.user_follows(user_id=53112486))

您无法再使用 Instagram APIs 获取其他用户的关注者,您只能获取已通过身份验证的用户的 followers/following 列表。您需要通过 instagram 审查和批准您的应用程序,然后进入实时模式才能访问 API 中的所有数据,并且您还需要 "followers_list" 范围许可。

问题第一部分的代码使用的是私人 Instagram API,不支持获取关注者列表。

(总之你把各地的代码搞混了,连关系都没有,一个是public api还有一个是private的api,你需要阅读文档)