Skip to content

Instantly share code, notes, and snippets.

@Mohsen322
Created April 7, 2020 08:37
Show Gist options
  • Save Mohsen322/c85bc801fd3fb85c37d01086da06a1f8 to your computer and use it in GitHub Desktop.
Save Mohsen322/c85bc801fd3fb85c37d01086da06a1f8 to your computer and use it in GitHub Desktop.
get telegram bot users Bio without API (PHP + Web Scrapping)
// Created: https://t.me/howCreateBot
function get_web_page( $url ){
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "spider", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_SSL_VERIFYPEER => false // Disabled SSL Cert checks
);
$ch = curl_init( $url );
curl_setopt_array( $ch, $options );
$content = curl_exec( $ch );
$err = curl_errno( $ch );
$errmsg = curl_error( $ch );
$header = curl_getinfo( $ch );
curl_close( $ch );
$header['errno'] = $err;
$header['errmsg'] = $errmsg;
$header['content'] = $content;
return $header;
}
$username = '';
$url = 'https://t.me/'.$username;
$data = get_web_page($url);
$data_content = $data['content'];
preg_match('/<div class="tgme_page_description ">([^<]+)<\/div>/i', $data_content, $matches);
$bio_text = $matches[1];
echo 'BIO = '.$bio_text;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment