我有代碼顯示我的粉絲數在頁面上,但我認為本周 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); // Removedcurl_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 個字符
1 回答

慕哥6287543
TA貢獻1831條經驗 獲得超10個贊
您可以使用此代碼。
<?php
$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('/"edge_followed_by"\:\{"count":(.*?)\}/',$data,$result);
echo $result[1];
我改變了正則表達式模式。它會起作用。
- 1 回答
- 0 關注
- 232 瀏覽
添加回答
舉報
0/150
提交
取消