elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Guía actualizada para evitar que un ransomware ataque tu empresa


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  Extraer url de imagen en codigo html
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Extraer url de imagen en codigo html  (Leído 7,797 veces)
octavioxd

Desconectado Desconectado

Mensajes: 52



Ver Perfil
Extraer url de imagen en codigo html
« en: 14 Julio 2010, 11:55 am »

Hola a todos que cuentan de nuevo  ;D les traigo otro problema mas para molestarlos me gustaria saber como puedo hacer un pequño codigo cuya funcion sea de un codigo HTML cualquiera extraiga la url de alguna iamgen que tenga adentro por ejemplo

Código
  1. <div>
  2. <img src = 'http://foreverdriven.files.wordpress.com/2009/07/embolado-3.jpg'/>
  3. </div>
  4.  

yo quiero que me extraiga y devuelva un string que solo diga esto http://foreverdriven.files.wordpress.com/2009/07/embolado-3.jpg
se que es medio dificil de hacer pero ustedes deberan tener experiencia en algun codigo como este!
saludos a todos y gracias por la buerna onda de siempre!!


En línea

‭lipman


Desconectado Desconectado

Mensajes: 3.062



Ver Perfil WWW
Re: Extraer url de imagen en codigo html
« Respuesta #1 en: 14 Julio 2010, 13:31 pm »

No se si te he entendido bien, pero allá voy:

Código
  1. $paginaWeb = '<div><img src="http://foreverdriven.files.wordpress.com/2009/07/embolado-3.jpg"></div>';
  2.  
  3. $trozos = explode('<img src="', $paginaWeb);
  4. //$trozos[0] = <div>
  5. //$trozos[1] = http://foreverdriven.files.wordpress.com/2009/07/embolado-3.jpg"></div>
  6.  
  7. $nuevotrozo = explode('">', $trozos[1]);
  8.  
  9. //$nuevotrozo[1] = (nada, está vacio)
  10.  
  11. //Y lo que queremos:
  12. //$nuevotrozo[0] = http://foreverdriven.files.wordpress.com/2009/07/embolado-3.jpg
  13.  

Un saludo!


En línea

Shell Root
Moderador Global
***
Desconectado Desconectado

Mensajes: 3.723


<3


Ver Perfil WWW
Re: Extraer url de imagen en codigo html
« Respuesta #2 en: 14 Julio 2010, 20:54 pm »

Prefiero las expresiones regulares... Mirad!
Código
  1. # Shell Root
  2. # Sacar urls de las imagenes
  3. # http://foro.elhacker.net/php/extraer_url_de_imagen_en_codigo_html-t299529.0.html
  4.  
  5.  function sacarURL($url){
  6.    $strArrayEliminar = array('<img src=', '\'', '"');
  7. $strContenidoPagina = file_get_contents($url);
  8. if(preg_match_all('/<img src=(\'|")((http|https|ftp|\/)\s*)([^\s]*)(\'|")/', $strContenidoPagina, $strResultado, PREG_SET_ORDER)){
  9.  foreach ($strResultado as $ExitResultado){
  10.    echo str_replace($strArrayEliminar,'',$ExitResultado[0])."\n";
  11.  }
  12. }
  13.  }
  14.  
  15.  sacarURL('http://foro.elhacker.net/php/extraer_url_de_imagen_en_codigo_html-t299529.0.html');
Poc:
Código
  1. shellroot@alex-laptop:~/Escritorio$ php PoC.php
  2. http://foro.elhacker.net/Themes/converted/selogo.jpg
  3. http://foro.elhacker.net/Themes/converted/der_logo.jpg
  4. http://foro.elhacker.net/Themes/converted/images/spanish/home.gif
  5. http://foro.elhacker.net/Themes/converted/images/spanish/help.gif
  6. http://foro.elhacker.net/Themes/converted/images/spanish/login.gif
  7. http://foro.elhacker.net/Themes/converted/images/spanish/register.gif
  8. http://personal.telefonica.terra.es/web/alexb/100622-ElHacker-728x90.gif
  9. http://foro.elhacker.net/Themes/converted/images/icons/folder_open.gif
  10. http://foro.elhacker.net/Themes/converted/images/icons/linktree_side.gif
  11. http://foro.elhacker.net/Themes/converted/images/icons/folder_open.gif
  12. http://foro.elhacker.net/Themes/converted/images/icons/linktree_main.gif
  13. http://foro.elhacker.net/Themes/converted/images/icons/linktree_side.gif
  14. http://foro.elhacker.net/Themes/converted/images/icons/folder_open.gif
  15. http://foro.elhacker.net/Themes/converted/images/icons/linktree_main.gif
  16. http://foro.elhacker.net/Themes/converted/images/icons/linktree_main.gif
  17. http://foro.elhacker.net/Themes/converted/images/icons/linktree_side.gif
  18. http://foro.elhacker.net/Themes/converted/images/icons/folder_open.gif
  19. http://foro.elhacker.net/Themes/converted/images/icons/linktree_main.gif
  20. http://foro.elhacker.net/Themes/converted/images/icons/linktree_main.gif
  21. http://foro.elhacker.net/Themes/converted/images/icons/linktree_main.gif
  22. http://foro.elhacker.net/Themes/converted/images/icons/linktree_side.gif
  23. http://foro.elhacker.net/Themes/converted/images/icons/folder_open.gif
  24. http://foro.elhacker.net/Themes/converted/images/spanish/go_down.gif
  25. http://foro.elhacker.net/Themes/converted/images/spanish/print.gif
  26. http://foro.elhacker.net/Themes/converted/images/topic/normal_post.gif
  27. http://foro.elhacker.net/Themes/converted/images/useroff.gif
  28. http://www.elhacker.net/foro/YaBBImages/avatars/spider_man.gif
  29. http://foro.elhacker.net/Themes/converted/images/icons/profile_sm.gif
  30. http://foro.elhacker.net/Themes/converted/images/post/xx.gif
  31. http://foro.elhacker.net/Smileys/chef/grin.gif
  32. http://foro.elhacker.net/Themes/converted/images/ip.gif
  33. http://foro.elhacker.net/Themes/converted/images/useroff.gif
  34. http://i43.tinypic.com/2ijlzit.jpg
  35. http://foro.elhacker.net/Themes/converted/images/icons/profile_sm.gif
  36. http://foro.elhacker.net/Themes/converted/images/www_sm.gif
  37. http://foro.elhacker.net/Themes/converted/images/post/xx.gif
  38. http://foro.elhacker.net/Themes/converted/images/ip.gif
  39. http://foro.elhacker.net/Themes/converted/images/spanish/go_up.gif
  40. http://foro.elhacker.net/Themes/converted/images/spanish/print.gif
  41. http://foro.elhacker.net/Themes/converted/images/blank.gif
  42. http://personal.telefonica.terra.es/web/alexb/images/minibannereol.gif
  43. http://personal.telefonica.terra.es/web/alexb/images/minibanner_lawebdegoku.gif
  44. http://personal.telefonica.terra.es/web/alexb/images/milw0rm_aff.gif
  45. http://personal.telefonica.terra.es/web/alexb/images/mundodivx.gif
  46. http://www.hispabyte.net/images/minibanners/mb_hispabyte_1.jpg
  47. http://personal.telefonica.terra.es/web/alexb/images/logo_et2.gif
  48. http://personal.telefonica.terra.es/web/alexb/images/todoreviews.gif
  49. http://personal.telefonica.terra.es/web/alexb/images/boton_zona-photo.gif
En línea

Por eso no duermo, por si tras mi ventana hay un cuervo. Cuelgo de hilos sueltos sabiendo que hay veneno en el aire.
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
extraer titulo de link html
Programación Visual Basic
usuario oculto 3 3,808 Último mensaje 6 Agosto 2011, 17:31 pm
por AlxSpy
Extraer Contorno a Objetos en Imagen Java
Java
alex.mg 3 3,626 Último mensaje 3 Septiembre 2013, 19:47 pm
por alex.mg
Extraer texto de html en bat ?
Scripting
novato04 2 2,846 Último mensaje 26 Agosto 2014, 12:15 pm
por Eleкtro
Extraer y copiar un sistema con todo su codigo.
Hacking
nimo 0 2,005 Último mensaje 25 Septiembre 2015, 17:17 pm
por nimo
Extraer partes de una imagen
Java
kur79 5 3,178 Último mensaje 23 Enero 2016, 22:57 pm
por Uzumaki_Naruto
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines