Good morning, I have the following error:
Warning: DOMDocument :: loadHTML (): Empty string supplied as input.
This error occurs on my free server, the strange thing is that locally everything works normal.
Does anyone know why?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/estilo.css" rel="stylesheet" type="text/css"/>
<script type="" src=""></script>
<script type="" src=""></script>
<link rel="" type="" href="">
<body>
<h2></h2>
<?php
$url = "https://www.agrolink.com.br/cotacoes/graos/";
$chll = curl_init();
curl_setopt($chll, CURLOPT_URL, $url);
curl_setopt($chll, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($chll, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($chll, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($chll, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($chll, CURLOPT_TIMEOUT, 120);
curl_setopt($chll, CURLOPT_POST,false);
//curl_setopt($chll, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($chll, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($chll, CURLOPT_VERBOSE, 1);
curl_setopt($chll, CURLOPT_ENCODING, "");
$err = curl_error($chll);
$mensagem = curl_exec($chll);
curl_close ($chll);
//echo $mensagem;
libxml_use_internal_errors(true) and libxml_clear_errors();
$html = new DOMDocument();
$html->loadHTML($mensagem);
$arra = array();
foreach($html->getElementsByTagName('td') as $span){
$x0 = $span->nodeValue.'</br>';
echo $x0.'</br>'.'</br>';
};
?>