Find data from an external page with file_get_contents

-1

I'm using the file_get_contents command because I want to get information from a website and paste that information into my page.

Can anyone help me implement the code so I can get this information?

// Endereço do site
$url = 'https://api.micetigri.fr/player/Leow%239880';

// Pegando dados do Site e colocando em uma String
$dadosSite = file_get_contents($url);

// Exibindo o retorno
echo $dadosSite;

Well, it does not matter how I can get the information I want below:

I just wanted to reproduce this result on my site.

    
asked by anonymous 13.07.2018 / 14:01

1 answer

1

You can capture this information using the preg_match () function, the code looks like this:

$url = "https://api.micetigri.fr/player/Leow%239880";
$contents = file_get_contents($url);
(bool) $operacao = preg_match("/<span id=\"ip_cliente\">(.*)<\/span>/", $contents, $dadosRetornados);

if($operacao)
    echo $dadosRetornados[1];
else
    echo "Falha na operação";

The first parameter of preg_match () is the regular expression to be executed, as you could see, I used a <span> mock for simulation, note in html where this value is returned and replace

    
13.07.2018 / 14:48