最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Scraping data from Instagram - Stack Overflow

programmeradmin0浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论