亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從 Instagram 獲取沒有 api 的粉絲數

從 Instagram 獲取沒有 api 的粉絲數

PHP
慕虎7371278 2021-12-03 15:21:15
我有代碼顯示我的粉絲數在頁面上,但我認為本周 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];

我改變了正則表達式模式。它會起作用。


查看完整回答
反對 回復 2021-12-03
  • 1 回答
  • 0 關注
  • 232 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號