Foros del Web » Programando para Internet » PHP »

expresiones regulares tomar datos html

Estas en el tema de expresiones regulares tomar datos html en el foro de PHP en Foros del Web. Hola gente. que tal?. Mis conocimientos de expresiones regulares son basicos y no doy con el siguiente problema necesito sacar primero todos los <a> que ...
  #1 (permalink)  
Antiguo 20/10/2009, 05:05
 
Fecha de Ingreso: octubre-2004
Ubicación: Uruguay
Mensajes: 386
Antigüedad: 19 años, 6 meses
Puntos: 4
expresiones regulares tomar datos html

Hola gente. que tal?.
Mis conocimientos de expresiones regulares son basicos y no doy con el siguiente problema
necesito sacar primero todos los <a> que tengan imagen <img></a>
luego de ese resultado he de tomar los "title" o "alt" de cada imagen . alguien sabria decirme como hacerlo ?
pd. cualqueir funcion me es valida: preg_match_all o preg_match o ereg.
pero necesito hacer eso en 3 pasos. me refiero a generar 3 expresiones regulares que puedan hacer eso.

Saludos Gerardo


Código:
<table width='600' border='0' cellspacing='0' cellpadding='0'align='center'>
<tr valign='top'>
 
<td align='center'><center><span style='font-size: 0.7em'><a href="http://www.dominio.com/pelicula/the-...ley-2008-vose/" title="The Haunting of Molly Hartley (2008) VOSE"><img width='100' height='144' src='dominio.comthumbs/the-haunting-of-molly-hartley-2008-vose.jpg' alt='The Haunting of Molly Hartley (2008) VOSE'/><br />The Haunting of Molly Hartley (2008) VOSE</a></span><br /><img src="dominio.comimages/tmegavideo.png" alt="Megavideo" style="vertical-align: middle;" /><img height="30" src="dominio.com/images/f/spanish-sub.png" alt="Subtítulos en Español" style="vertical-align: middle;" /></center></td><td align='center'><center><span style='font-size: 0.7em'><a href="http://www.dominio.com/pelicula/moon-2009-dvdscreener2/" title="Moon (2009) DVDScreener2"><img width='100' height='144' src='dominio.comthumbs/moon-2009-dvdscreener2.jpg' alt='Moon (2009) DVDScreener2'/><br />Moon (2009) DVDScreener2</a></span><br /><img src="dominio.comimages/tmegavideo.png" alt="Megavideo" style="vertical-align: middle;" /><img height="30" src="dominio.com/images/f/spanish.png" alt="Audio Español" style="vertical-align: middle;" /></center></td><td align='center'><center><span style='font-size: 0.7em'><a href="http://www.dominio.com/pelicula/a-po...9-dvdscreener/" title="A por todas: La lucha final (2009) DVDScreener"><img width='100' height='144' src='dominio.comthumbs/a-por-todas-la-lucha-final-2009.jpg' alt='A por todas: La lucha final (2009) DVDScreener'/><br />A por todas: La lucha final (2009) DVDScreener</a></span><br /><img src="dominio.comimages/tmegavideo.png" alt="Megavideo" style="vertical-align: middle;" /><img height="30" src="dominio.com/images/f/spanish.png" alt="Audio Español" style="vertical-align: middle;" /></center></td><td align='center'><center><span style='font-size: 0.7em'><a href="http://www.dominio.com/pelicula/expe...-dvdscreener6/" title="Expediente 39 (2009) DVDScreener6"><img width='100' height='144' src='dominio.comthumbs/expediente-39-2009-dvdscreener6.jpg' alt='Expediente 39 (2009) DVDScreener6'/><br />Expediente 39 (2009) DVDScreener6</a></span><br /><img src="dominio.comimages/tmegavideo.png" alt="Megavideo" style="vertical-align: middle;" /><img height="30" src="dominio.com/images/f/spanish.png" alt="Audio Español" style="vertical-align: middle;" /></center></td><td align='center'><center><span style='font-size: 0.7em'><a href="http://www.dominio.com/pelicula/no-h...-2007-dvdrip1/" title="No hables con extraños (2007) DVDRip1"><img width='100' height='144' src='dominio.comthumbs/no-hables-con-extranos-2007-dvdrip1.jpg' alt='No hables con extraños (2007) DVDRip1'/><br />No hables con extraños (2007) DVDRip1</a></span><br /><img src="dominio.comimages/tmegavideo.png" alt="Megavideo" style="vertical-align: middle;" /><img height="30" src="dominio.com/images/f/spanish.png" alt="Audio Español" style="vertical-align: middle;" /></center></td></tr>
</table>
  #2 (permalink)  
Antiguo 20/10/2009, 08:20
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: expresiones regulares tomar datos html

lee el siguiente tema... sirve que aprendes algo
http://www.forosdelweb.com/f18/aport...s-pcre-646110/
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 20/10/2009, 08:41
 
Fecha de Ingreso: octubre-2004
Ubicación: Uruguay
Mensajes: 386
Antigüedad: 19 años, 6 meses
Puntos: 4
Respuesta: expresiones regulares tomar datos html

gracias por la ayuda, pero me cuesta bastante entenderlo - Si hay algun alma caritativa que me ayude . estare muy agradecido XD
  #4 (permalink)  
Antiguo 20/10/2009, 09:17
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: expresiones regulares tomar datos html

es muy simple... primero debes usar preg_match_all()

sacar los <a/>
Código:
/<a[^>]*></a>/
luego las imágenes... usando los matches, claro
Código:
/<img[^>]*\/?>/
luego iteras los matches aplicando mas reglas... (sobre los atributos)
Código:
/(\w+)="(\w+)"/
ahora, con los atributos ya capturados... puedes hacer lo que quieras!!


NOTA que no creo que alguien te de el código ya hecho, es mucho pedir... supongo
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
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 18:20.