Not recommended! but I used the function preg_match_all
For that I created a simple Pattern, to obtain the respective values. However, with only the function file_get_contents()
could not locate this data, because the site redirects to login area, because it does not contain the sessions and/or cookies in the request. That’s why I created a call curl
for the given url. In fact it works! even without logging in to the page, as follows:
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => "https://pt.clubcooee.com/settings/changename?token=24075208-1660433091-a355f7ce9bc39f2e8a2a09f30107ca3d&ms=1",
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_HTTPHEADER => array(
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Connection: keep-alive",
"Upgrade-Insecure-Requests: 1",
"Host: pt.clubcooee.com",
"User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 Edg/92.0.902.67"
),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_COOKIESESSION => true,
CURLOPT_COOKIEFILE => "cookie.log",
CURLOPT_COOKIEJAR => "cookie.log",
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4
));
After the above code, I created a variable called $dados
to execute Curl parameters.
$dados = curl_exec($ch);
Next comes the function preg_match_all
preg_match_all('/<h3 class="font-m">([^<]*)<\/h3>([^.\r\n]*)<\/div>/', $dados, $matches, PREG_SET_ORDER);
I used the flag PREG_SET_ORDER
for the matrix data to be returned in an orderly manner!
However, just print the result on the page!
echo trim(strip_tags($matches[0][0]));
the function strip_tags()
serves to remove html tags present between texts, such as <br>
and etc..
"Your name changes so far 06/08/21 21:25 testbug01425451 -> testbug00071"
Use an HTML parser. See Domdocument::loadHTML
– Augusto Vasques
This would not work, I need to make a request on the site login.
– LODSX