如何在2020年instagram api更改后从instagram公共帐户获取instagram关注者人数?

时间:2020-09-02 16:44:01

标签: instagram instagram-api

我试图仅使用用户的instagram句柄(又名@myusername)来检索关注者计数。我读了几个答案,您可以访问“ https://www.instagram.com/{username}/?__a=1”以检索包含所有详细信息的json块。但是,当我尝试在api更改后的2020年现在尝试执行此操作时,该URL会将我重定向到登录页面。

我也查看了instagram基本的显示/图形api,但似乎找不到找到其他用户关注者人数的方法。

摘自ig基础显示api官方文档:https://developers.facebook.com/docs/instagram-basic-display-api/reference/user
此API仅允许您获取account_type,id,ig_id(即将弃用),媒体数和用户名。 (没有关注者人数的迹象)

从官方ig图api文档中: https://developers.facebook.com/docs/instagram-api
“该API无法访问Intagram消费者帐户(即非企业帐户或非创建者Instagram帐户)。如果您要为消费者用户构建应用程序,请改用Instagram基本显示API。”

由于我的程序假设要从不一定专业的帐户中检索关注者人数,所以我似乎无法弄清楚该怎么做...

结论:

  • 我尝试过网络抓取->重定向到登录页面
  • 基本显示api->无法获得关注者人数
  • 图形API->无法访问消费者帐户

有人对此有解决方案吗?

谢谢!

2 个答案:

答案 0 :(得分:0)

您可以使用Instaloader Python模块。 这是一个简短的示例:

import instaloader
L = instaloader.Instaloader()
user = "IG_USERNAME"
password = "IG_PASSWORD"
L.login(user, password)
profile = instaloader.Profile.from_username(L.context, user)

print(profile.followees) #number of following
print(profile.followers) #number of followers
print(profile.full_name) #full name
print(profile.biography) #bio
print(profile.profile_pic_url)  #profile picture url 
print(profile.get_posts()) #list of posts
print(profile.get_followers()) #list of followers
print(profile.get_followees()) #list of followees

答案 1 :(得分:0)

Instagram阻止了您的IP ...您需要使用未检测到的代理来从Instagram抓取该消息,通常是通过的住宅IP。

将HTTP请求发送到IG API结束>如果收到JSON响应,则表示它很好并且未被检测到,否则它被检测到代理并且对Instagram不利。

为此的代码(在c#中,但可以遵循python中的相同逻辑):

    ltpa -> a : 123456789012345678901234                                                                                                                                               
    ltpa -> b : 1                                                                                                                                                                      
    ltpa -> c : 2345678901234                                                                                                                                                          
    ltpa -> d : 78901234

如果您问为什么Instagram会阻止某些IP?只是Instagram拥有一个庞大的数据库,其中包含过去发送的IP数量超出了允许的限制请求……他们这样做是为了防止抓取。

相关问题