Grab Instagram Follower count

后端 未结 2 557
予麋鹿
予麋鹿 2021-02-06 00:43

So I have a question what would be the method to just grab the instagram follower count for a said user?

I have looked at two possible options the official instagram AP

相关标签:
2条回答
  • 2021-02-06 01:26

    You can request https://www.instagram.com/<username>/?__a=1 and receive JSON with account information also with followers count as well. It doesn't need authorization.

    0 讨论(0)
  • 2021-02-06 01:38

    The link from the accepted answer (https://www.instagram.com/<username>/?__a=1) no longer seems to work, but we can still get followers count from parsing the html from the normal profile url https://www.instagram.com/<username>

    If you do a GET request, you'll get the plain HTML and you can search an html tag that looks like <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" />

    You can try it out in your browser by going to an Instagram profile, then right click and viewing the page source. Then it's just a matter of parsing the text to get the info you want.

    Here's an example to get the number of followers in 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])
        }
     });
    

    This is probably not a reliable, future-proof approach, but it does seem to work for now.

    0 讨论(0)
提交回复
热议问题