Error simple html dom

  • Autor Autor Andresledo
  • Fecha de inicio Fecha de inicio
A

Andresledo

Gamma
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
Buenos días,

Tengo un problema con el simple html get que no acabo de resolver, en local me da el error siguiente en appserver con PHP, sin embargo, en el hosting funciona correctamente el mismo código.

Warning: file_get_contents(): stream does not support seeking in C:\AppServ\www\scrap\simple_html_dom.php on line 75

Warning: file_get_contents(): Failed to seek to position -1 in the stream in C:\AppServ\www\scrap\simple_html_dom.php on line 75

Fatal error: Uncaught Error: Call to a member function find() on boolean in C:\AppServ\www\scrap\index.php:6 Stack trace: #0 {main} thrown in C:\AppServ\www\scrap\index.php on line 6

Supongo que me falta alguna extensión en PHP o algo por el estilo...

El código que utilizo es el siguiente:

<?php

include ("simplehtmldom.php");

$html = file_get_html('http://www.google.com/');

// Find all images
foreach($html->find('img') as $element)
echo $element->src . '<br>';

// Find all links
foreach($html->find('a') as $element)
echo $element->href . '<br>';
?>
 
Seguro te falta habilitar curl en el php.ini


Enviado mediante Tapatalk
 
PHP:
<?php

include ("simplehtmldom.php");

$data = file_get_html('http://www.google.com/');

$html = new simple_html_dom();
$html->load($data);

// Find all images
foreach($html->find('img') as $element)
{
	echo $element->src . '<br>';
}
// Find all links
foreach($html->find('a') as $element)
{
	echo $element->href . '<br>';
}

?>

Así debería de funcionar.. al menos a mi me funciona

- - - Actualizado - - -

Simple HTML Dom no usa curl

Enviado desde mi XT1097 mediante Tapatalk

Si que se puede utilizar curl con simple html dom 😀
 
Última edición:
Que tal estimado? Usa este ejemplo $part = substr($name, 849, 32); donde $name es el nombre del sitio Web al que quieres hacerle scrapping. Al parecer file_get_html('http://www.google.com/'); no funciona con archivos remotos.
 
¿Y qué tal va con file_get_contents?
 
Atrás
Arriba