我有代码显示我的粉丝数在页面上,但我认为本周 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 关注
- 195 浏览
添加回答
举报
0/150
提交
取消