抓住Instagram追随者数量

Bak*_*ker 4 javascript php api instagram

所以我有一个问题是什么方法只是为所述用户获取Instagram粉丝数量?

我已经看了官方instagram API的两个可能的选项,但我找不到一个如何命名的特定方法,但他们确实有一些用户端点,但找不到很多细节,或者我在想关于使用非官方的Instagram API https://github.com/mgp25/Instagram-API

有小费吗?

ily*_*apt 10

您也可以https://www.instagram.com/<username>/?__a=1通过帐户信息请求和接收JSON,也可以关注关注者.它不需要授权.

  • “instagram.com/$username/?__a=1”解决方案有效,但几周后,Instagram 会阻止该域,因此系统无法获取关注者计数以显示在我们的网站上。我在 2 个域/网站上遇到了这个问题。 (2认同)

Lul*_*Cow 5

来自已接受答案 ( https://www.instagram.com/<username>/?__a=1)的链接似乎不再有效,但我们仍然可以通过解析来自普通个人资料 url 的 html 来获得关注者计数https://www.instagram.com/<username>

如果您发出GET请求,您将获得纯 HTML,并且您可以搜索如下所示的 html 标签<link rel="canonical" href="https://www.instagram.com/<username>/" /><meta content="359 Followers, 903 Following, 32 Posts - See Instagram photos and videos from <username>)" name="description" />

您可以通过访问 Instagram 个人资料在浏览器中试用它,然后右键单击并查看页面源。然后只需解析文本以获取您想要的信息。

这是在javascript中获取关注者数量的示例:

var url = "https://www.instagram.com/username";
request.get(url, function(err, response, body){
    if(response.body.indexOf(("meta property=\"og:description\" content=\"")) != -1){
        console.log("followers:", response.body.split("meta property=\"og:description\" content=\"")[1].split("Followers")[0])
    }
 });
Run Code Online (Sandbox Code Playgroud)

这可能不是一种可靠的、面向未来的方法,但它现在似乎确实有效。