从 Instagram 获取没有 api 的粉丝数

我有代码显示我的粉丝数在页面上,但我认为本周 instagram 更新了网站,使用 curl 时不再在个人资料中显示粉丝数


这是我以前工作过的代码:


$ch = curl_init();

$url = 'https://www.instagram.com/example';

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_HEADER, 1);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($ch, CURLOPT_USERAGENT, 'Googlebot/2.1 (http://www.googlebot.com/bot.html)');

curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);

//curl_setopt($ch, CURLOPT_TIMEOUT, 1); // Removed

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Added

$data = curl_exec($ch);

preg_match('/<meta content="([0-9]+).*Followers/',$data,$result);

echo $result[1];

这是为什么缺少关注者计数器的视图源:


http://pasted.co/ad3dc7d2


我无法在此处发布观看分数,因为此处限制为 30.000 个字符


慕虎7371278
浏览 196回答 1
1回答

慕哥6287543

您可以使用此代码。<?php&nbsp;$ch = curl_init();$url = 'https://www.instagram.com/example';curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_HEADER, 1);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);curl_setopt($ch, CURLOPT_USERAGENT, 'Googlebot/2.1 (http://www.googlebot.com/bot.html)');curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);//curl_setopt($ch, CURLOPT_TIMEOUT, 1); // Removedcurl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Added$data = curl_exec($ch);preg_match('/"edge_followed_by"\:\{"count":(.*?)\}/',$data,$result);echo $result[1];我改变了正则表达式模式。它会起作用。
打开App,查看更多内容
随时随地看视频慕课网APP