我正在尝试找到一个电报频道成员计数,而没有任何图书馆。
当我们打开此链接时,我们可以看到计数: https://t.me/{telegram channel id}/
是否可以使用file_get_contents函数提取计数?
简短的答案是"是的,可能是可能的":
$html = file_get_contents('https://t.me/CHANNEL_NAME');
preg_match_all('#(.*?) members, (.*?) online#', $html, $matches);
$members = (int) filter_var($matches[1][0], FILTER_SANITIZE_NUMBER_INT);
$online = (int) filter_var($matches[2][0], FILTER_SANITIZE_NUMBER_INT);
但是,这种方式是不可靠的:Telegram Devs可能会改变其HTML结构,并且此答案变得过时了。