Reputation: 1
I am trying to find a Telegram channel members count without any libraries in php.
When we open this link we can see the count:
https://t.me/{telegram channel id}/
Is it possible to extract the count with file_get_contents function?
Upvotes: 0
Views: 665
Reputation: 1146
The short answer is "yes, it is possible":
$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);
However, this way is unreliable: telegram devs may change their HTML structure and this answer become out-of-date.
Upvotes: 1