DomDocument - loadHtml - Problema

  • Autor Autor Lopezito
  • Data de início Data de início
Tradução em andamento: em alguns minutos este tópico estará em português. Por enquanto, o conteúdo está no original em espanhol. Ver original
Status

🔒 Este tópico está fechado para novas respostas.

⏰ Apenas o criador do tópico pode solicitar a reabertura de seus próprios tópicos, mas apenas dentro dos 60 dias anteriores à última atualização.

Lopezito

Lopezito

Eta
Diseñador
Verificación en dos pasos activada
Buenas
Estoy tratando de leer una web y sustraer parte del contenido, en este caso para testear use Google:

PHP:
<?php
$doc = new DomDocument;
$doc->validateOnParse = true;
$doc->loadHtml(file_get_contents('http://google.com/'));
$footer = $doc->getElementById('footer');
var_dump($doc->getElementById('footer'));
?>

Pero me tira los siguientes errores:

Inserir CODE, HTML ou PHP:
Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 41 in /home/user/public_html/index.php on line 4

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 41 in /home/user/public_html/index.php on line 4

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 41 in /home/user/public_html/index.php on line 4

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 41 in /home/user/public_html/index.php on line 4

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 41 in /home/user/public_html/index.php on line 4

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 41 in /home/user/public_html/index.php on line 4

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 41 in /home/user/public_html/index.php on line 4

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 41 in /home/user/public_html/index.php on line 4

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 41 in /home/user/public_html/index.php on line 4

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 41 in /home/user/public_html/index.php on line 4

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 41 in /home/user/public_html/index.php on line 4

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 41 in /home/user/public_html/index.php on line 4

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 41 in /home/user/public_html/index.php on line 4

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: no name in Entity, line: 41 in /home/user/public_html/index.php on line 4

Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 41 in /home/user/public_html/index.php on line 4
object(DOMElement)#2 (17) { ["tagName"]=> string(4) "span" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(4) "span" ["nodeValue"]=> string(107) "Advertentieprogramma'sBedrijfsoplossingen+GoogleAlles over GoogleGoogle.com© 2013 - Privacy en voorwaarden" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(4) "span" ["baseURI"]=> NULL ["textContent"]=> string(107) "Advertentieprogramma'sBedrijfsoplossingen+GoogleAlles over GoogleGoogle.com© 2013 - Privacy en voorwaarden" }
 
Foi útil? Participe da conversa

Com sua conta grátis você pode responder, mandar mensagem privada ao autor e comprar com Saldo retido: o pagamento é liberado quando você recebe o combinado.

Leva 30 segundos · você volta a este tópico ao terminar
Buenas
Estoy tratando de leer una web y sustraer parte del contenido, en este caso para testear use Google:

PHP:
<?php
$doc = new DomDocument;
$doc->validateOnParse = true;
$doc->loadHtml(file_get_contents('http://google.com/'));
$footer = $doc->getElementById('footer');
var_dump($doc->getElementById('footer'));
?>

Pero me tira los siguientes errores:
agrega esto antes del loadhtml. tons no verifica los errores html.
PHP:
$doc->strictErrorChecking = false;
 
agrega esto antes del loadhtml. tons no verifica los errores html.
PHP:
$doc->strictErrorChecking = false;

Si pongo eso no saca los errores, pero use @$doc en la linea donde use loadHtml, pero resulta que ahora tengo otro error:

---------- Post agregado el 07-mar-2013 hora: 04:25 ----------

Listo ya fixee los errores.
Muchas gracias [MENTION=9679]cicklow[/MENTION] :encouragement:
 
Status

🔒 Este tópico está fechado para novas respostas.

⏰ Apenas o criador do tópico pode solicitar a reabertura de seus próprios tópicos, mas apenas dentro dos 60 dias anteriores à última atualização.

Voltar
Topo