如何获得公开的Instagram用户关注者/关注者列表?

时间:2019-03-14 06:40:29

标签: api instagram

我知道这个问题是asked before,但是这些解决方案不再起作用。 Instagram已多次更改其API,也使获取数据变得更加困难。

是否有一种新方法来获取公共用户关注的关注者和人员列表?

1 个答案:

答案 0 :(得分:1)

Instaloader是处理此类问题的好工具,here for the official page

如果要获取公开个人资料的关注者和关注者的列表,请尝试

login_name = 'INSERT-YOUR-LOGIN-NAME-HERE'

target_profile = 'INSERT-TARGET-PROFILE-HERE'
# OR
#import sys
#target_profile = sys.argv[1] # pass in target profile as argument

from instaloader import Instaloader, Profile
loader = Instaloader()

# login
try:
    loader.load_session_from_file(login_name)
except FileNotFoundError:
    loader.context.log("Session file does not exist yet - Logging in.")
if not loader.context.is_logged_in:
    loader.interactive_login(login_name)
    loader.save_session_to_file()

profile = Profile.from_username(loader.context, target_profile)
followers = profile.get_followers()
followees = profile.get_followees()

loader.context.log()
loader.context.log('Profile {} has {} followees and {} followers:'.format(profile.username, profile.followees, profile.followers))
loader.context.log()

for followee in followees:
    loader.context.log(followee.username, flush=True)

for follower in followers:
    loader.context.log(follower.username, flush=True)