DomDocument - loadHtml - Problema

  • Autor Autor Lopezito
  • Fecha de inicio Fecha de inicio
Estado

🔒 Este tema está cerrado para nuevas respuestas.

⏰ Solo el creador del tema puede solicitar la reapertura de sus propios temas, pero únicamente dentro de los 60 días previos a la última actualización.

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:

Insertar CODE, HTML o 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" }
 
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:
 
Estado

🔒 Este tema está cerrado para nuevas respuestas.

⏰ Solo el creador del tema puede solicitar la reapertura de sus propios temas, pero únicamente dentro de los 60 días previos a la última actualización.

Atrás
Arriba