skip to Main Content

I actually just need the followers count of a public account,
for example https://www.instagram.com/kygomusic/

The new Instagram’s API rules are very strict (and discussed):
It’s now impossible to access public content for most of common apps. You need a public_content scope that is not granted to normal app (?!)

public_content: This permission (public_content) is only granted to
apps that enable brands, advertisers, broadcasters and publishers to
discover public content. We do not grant access to apps that do not
fall into these categories. Please review our documentation
(https://www.instagram.com/developer/review) for more information.

So I decided to scrape the data from Instagram

An option is to use file_get_contents() (PHP) and it works but it loads all the site from my server and it’s pretty heavy. So my first idea was to use YQL. I use it for Twitter and works well, but when I scrape data from Instagram I get nothing:

http://developer.yahoo.com/yql/console/?q=select%20*%20from%20html%20where%20url%3D’https%3A%2F%2Fwww.instagram.com%2Fkygomusic%2F’&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys

2

Answers


  1. I took a look into the page you submitted, it’s not that heavy, considering that you won’t load images or process js. While inspecting I found out that they have a json where they store their data.

    …. “followed_by”: {“count”: 924725}

    I didn’t had time to test this, but it should work, or at least you get the point of using it. CURL may be a better option because it can handle multithreaded requests.

    $url = 'https://www.instagram.com/kygomusic/';
    $str = file_get_contents($url);
    $count = 0;
    if(preg_match('#followed_by": {"count": (.*?)}#', $str, $match)) {
         $count = $match[1]; // get the count from Regex pattern
    } echo $count;
    
    Login or Signup to reply.
  2. Check this library: https://github.com/raiym/instagram-php-scraper you can get count of followers and follows and get almost any public info shared on instagram without auth.

    It is based on JSON responses that I and community have found and it is pretty lightweight

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search