Ver Mensaje Individual
  #3 (permalink)  
Antiguo 03/10/2007, 00:03
Avatar de Gerald
Gerald
 
Fecha de Ingreso: julio-2003
Mensajes: 1.356
Antigüedad: 20 años, 10 meses
Puntos: 2
Re: extraer texto de pagina html

Código PHP:
<?php

$url 
'datos.html';

// Obtengo el contenido de la web
$text file_get_contents($url);
//function to get a substring between between two other substrings

function substring_between($haystack,$start,$end) {
    if (
strpos($haystack,$start) === false || strpos($haystack,$end) === false) {
        return 
false;
    } else {
        
$start_position strpos($haystack,$start)+strlen($start);
        
$end_position strpos($haystack,$end);
        return 
substr($haystack,$start_position,$end_position-$start_position);
    }
}

$text htmlspecialchars($text);
$title substring_between($text,'&lt;title&gt;','&lt;/title&gt;');
echo 
$title;
?>
Por ahora tengo esto y me imprime lo que esta en <title></title> pero al querer lo que esta en <div align="center" class="ensbustermenu">-0.88</div> no me imprime nada.
Que estoy haciendo mal?
__________________
Solo por Hoy: Trataré de fortalecer mi mente. Estudiaré y aprenderé algo útil
Hoteldipity
Arte Caracol