我其实只需要一个公众号的关注者数量, 例如https://www.instagram.com/kygomusic/
新的 Instagram 的 API 规则非常严格(并进行了讨论): 现在无法访问大多数常见应用的公共(public)内容。您需要一个未授予普通应用程序的 public_content 范围(?!)
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.
所以我决定从 Instagram 抓取数据
一个选项是使用 file_get_contents() (PHP),它可以工作,但它会从我的服务器加载所有网站,而且非常繁重。所以我的第一个想法是使用YQL。我将它用于 Twitter 并且运行良好,但是当我从 Instagram 抓取数据时,我什么也得不到:
最佳答案
我看了一下你提交的页面,考虑到你不会加载图片或处理js,它并没有那么重。在检查时我发现他们有一个 json 来存储数据。
....“followed_by”:{“count”:924725}
我没有时间测试这个,但它应该可以工作,或者至少你明白使用它的意义。 CURL 可能是一个更好的选择,因为它可以处理多线程请求。
$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;
关于javascript - 从 Instagram 抓取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37993827/