2017-03-03 76 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

相關問題