2017-03-03 77 views
0

如何在instagram中获取用户的每个追随者的用户名?在json中,我只能访问关注者的数量。 这里是JSON处理的URL我使用:在Instagram中使用Scrapy或Instagram访问用户的所有追随者的用户名Python API

"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但这是公共帐户,我可以看到BuzzFeed使用的追随者它的instagram帐户。任何想法都被强烈建议。

更新: 我试图通过使用Instagram的API此另一种方法,我也得到无,不知道哪里出了问题:

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

它问我: enter image description here

其中我的授权!

这就是说,我可以让我自己的帐户数(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": []} 

这些都返回([], 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)) 
+0

貌似端点得到用户的追随者是这样的:'https://api.instagram.com/v1/users/USERID/followed-by?access_token = ACCESSTOKENcount = -1'。有关Instagram API的更多信息,请参阅https://www.instagram.com/developer/endpoints/relationships/ – eLRuLL

+0

请检查帖子的最后几行,它甚至没有为自己工作:/ –

+1

http ://stackoverflow.com/questions/41286489/instagram-api-not-returning-followers @MonaJalal –

回答

1

使用的Instagram的API了,你只能得到追随者/以下列表对于被认证的用户无法获得其他用户的追随者。您需要通过instagram审核并批准您的应用,然后转到LIVE模式才能访问API中的所有数据,并且您还需要“followers_list”范围权限。

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

(总之你刚才混淆代码来自全国各地的地方,它甚至没有相关的,一个是公开的API和其他私有API,你需要阅读的文档)

+0

只是一个简单的问题,如果我上线,我是否仍然只能从自己的追随者或任何公共用户的追随者那里获取数据? –

+0

是的,只是你的追随者 – krisrak

相关问题