Grab Instagram Follower count

北城以北 提交于 2020-06-25 00:41:42

问题


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 API, but I couldn't find a specific method named on how to do so, but they do have a some user endpoints, but couldn't find much detail on it or I was thinking about using the unofficial instagram API https://github.com/mgp25/Instagram-API

Any tips?


回答1:


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.




回答2:


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.




回答3:


   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])
    }
 });

It seems like this is throwing an error message -> ReferenceError: request is not defined Any assistance will be appreciated



来源:https://stackoverflow.com/questions/39822860/grab-instagram-follower-count

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!