Foros del Web » Programando para Internet » PHP »

Como puedo parse html con php ???

Estas en el tema de Como puedo parse html con php ??? en el foro de PHP en Foros del Web. este my code Código PHP: $input  =  file_get_contents ( $url );  if ( preg_match_all ( '/class="lyrics"([^\"]*)\">(.*)<\/td>/iU' , $input ,  $matches )){  echo  $matches [ 2 ]; ...
  #1 (permalink)  
Antiguo 25/12/2008, 01:15
 
Fecha de Ingreso: diciembre-2008
Mensajes: 1
Antigüedad: 15 años, 3 meses
Puntos: 0
Mensaje Como puedo parse html con php ???

este my code
Código PHP:
$input file_get_contents($url); 

if (
preg_match_all('/class="lyrics"([^\"]*)\">(.*)<\/td>/iU',$input$matches)){
 echo 
$matches[2];
  } 
y aqui code html quiero parse

Código HTML:
<html>
<head>
<title>Print Beth Orton - Pieces Of Sky</title>
<link rel="stylesheet" type="text/css" href="/i/css.css">
</head>
<body onload="window.print();">
<table cellpadding="0" cellspacing="0" style="width:220mm" align="center">
	<tr>
		<td valign="top" style="font:normal 22px Trebuchet MS;padding:40px;padding-botoom:0px;padding-top:20px;height:40px">Beth Orton - Pieces Of Sky lyrics</td>
	</tr>
	<tr>

		<td style="padding:40px;padding-top:0px" class="lyrics" valign="top">
		These memories are just pieces of sky<br />
Pieces of something much bigger than I<br />
To anyone else just endless blue<br />
I see time framed, an image of you<br />
These memories hold me like the moon<br />
Holds the sea like the sky holds the sun<br />
The sea holds my tears and carries me<br />

When my heart is too heavy for one<br />
<br />
When it's over, it's over<br />
I best get busy living <br />
Been a long time gone<br />
<br />
A dress made of air and webs and dew<br />
The way dreams evaporate as they come true<br />
To anyone else just endless blue<br />
An invisible kite string connects me to you<br />

I know that it's selfish to think you'd come here<br />
There's so many people that must need you near<br />
There's so many people that need to know<br />
That you're still with them even when you go<br />
That you're still with them even when they don't know<br />
<br />
When it's over, it's over<br />
I best get busy living<br />
You'll be a long time gone<br />

And how do you know how much you'll be missed<br />
Does it add up to some names on a list<br />
Do you know we're just pieces of sky<br />
Pieces of time that keep drifting by		</td>
	</tr>
	<tr>
		<td valign="top" style="padding:40px;padding-top:0px"></td>
	</tr>

</table>
</body>
</html> 
Solo quiero tomar lyric en
Código HTML:
<td style="padding:40px;padding-top:0px" class="lyrics" valign="top">
Lyric quiero tomar
</td> 
Porfavor ayudarme.. Mil gracias
  #2 (permalink)  
Antiguo 26/12/2008, 08:05
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Como puedo parse html con php ???

¿por qué no mejor detallás cuál es el error que te aparece?
Porque en principio el patrón que estás usando es correcto.

Código:
#<td .*class="lyrics".*>(.*)</td>#U

Saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:08.