I've been looking at Ifood's website. What happens is that the site detects which browser is requesting the page before sending the content. When it identifies that it is PHP, it returns an error.
I tried to circumvent the process with a Stream but it also did not work.
<?php
// configura o stream e as opções de Headers(cabeçalhos)
$stream = stream_context_create(
Array("http" => Array("method" => "GET",
"timeout" => 30,
"header" => "User-agent:".$_SERVER['HTTP_USER_AGENT'],
"Accept"=> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"Accept-Encoding"=> " gzip, deflate, br",
"Accept-Language"=> " pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7",
"Cache-Control"=> " max-age=0",
"Connection"=> " keep-alive",
"Host"=> " www.ifood.com.br",
"Upgrade-Insecure-Requests"=> 1
)));
if ( $arquivo = fopen("https://www.ifood.com.br/delivery/belo-horizonte-mg/puro-sabor-salgados---carlos-prates-carlos-prates", 'r', false, $stream) ) {
}
while(!feof($arquivo))
{
//Mostra uma linha do arquivo
$linha = fgets($arquivo);
echo $linha;
}?>