admin管理员组

文章数量:1323317

I actually just need the followers count of a public account, for example /

The new Instagram's API rules are very strict (and discussed): It's now impossible to access public content for most of mon 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 () 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:

/?q=select%20*%20from%20html%20where%20url%3D'https%3A%2F%2Fwww.instagram%2Fkygomusic%2F'&env=store%3A%2F%2Fdatatables%2Falltableswithkeys

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

The new Instagram's API rules are very strict (and discussed): It's now impossible to access public content for most of mon 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./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./yql/console/?q=select%20*%20from%20html%20where%20url%3D'https%3A%2F%2Fwww.instagram.%2Fkygomusic%2F'&env=store%3A%2F%2Fdatatables%2Falltableswithkeys

Share asked Jun 23, 2016 at 13:59 Sebastien HorinSebastien Horin 11.1k4 gold badges54 silver badges55 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 5

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./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;

Check this library: https://github./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 munity have found and it is pretty lightweight

本文标签: javascriptScraping data from InstagramStack Overflow