Tema: Parsear THML
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/11/2017, 18:14
Lechu_
 
Fecha de Ingreso: enero-2010
Mensajes: 128
Antigüedad: 14 años, 4 meses
Puntos: 2
Parsear THML

Hola

Estuve usando simple_html_dom.php, para parcear un html, pero no funciona el file_get_html

Estuve haciendo esta prueba

Código:
<?php
include("simplehtmldom_1_5/simple_html_dom.php");
// Create DOM from URL 
$html = file_get_html('http://google.com'); 
	
// Find all article blocks 
foreach($html->find('div.article') as $article) { 
    $item['title']     = $article->find('div.title', 0)->plaintext; 
    $item['intro']    = $article->find('div.intro', 0)->plaintext; 
    $item['details'] = $article->find('div.details', 0)->plaintext; 
    $articles[] = $item; 
} 

print_r($articles);  

?>
Pero me salen estos errores:
Warning: file_get_contents(): stream does not support seeking in

Warning: file_get_contents(): Failed to seek to position -1 in the stream in ...line 75

Fatal error: Uncaught Error: Call to a member function find() on boolean...

Ent. se me ocurrio usar:

$html = file_get_contents('http://google.com');
echo $html;

obtengo el HTML, pero yo quiero obtener algunos Div en particular (y sus hijos) ¿como puedo saber donde termina ese Div? asi uso alguna funcion de manejo de String y obtengo la porcion del html que necesito

Gracias.-
__________________
Por favor evitar comentarios del estilo "leer el manual...", ya lo hice pero aun tengo dudas, por eso pregunto acá