Detectar Links y meter en un array

Iniciado por Auton, 18 Junio 2011, 11:31 AM

0 Miembros y 1 Visitante están viendo este tema.

Nakp

#10
yo pienso que esto hace el trabajo :¬¬

Código (php) [Seleccionar]
$pat = '/<a.+href=[\"\']([a-z\/:\.\%\-\_0-9\s]+)[\"\']/i';
preg_match_all($pat, $data, $urls);
var_dump($urls[1]);





pa quien quiera probar
http://regex.larsolavtorvik.com/

le agregue el espacio porque hay gente que le da la gana escribirlos en vez de %20 xD
Ojo por ojo, y el mundo acabará ciego.

~ Yoya ~

#11
Si, vivan las expresiones regulares xD. Muy buena la pagina Nakp, usaba otra pero era en Flash.

Código (php) [Seleccionar]
<?php
$contenido 
file_get_contents('http://foro.elhacker.net/');

preg_match_all('/<a[^=]+=(?:\"|\')((?i).+(?-i))(?:\"|\')>(.+)<\/a>/',$contenido$resultPREG_SET_ORDER);

print_r($result);
?>


Salida:
[87] => Array
       (
           [0] => <a href="http://foro.elhacker.net/profiles/azielito-u5350.html">Azielito</a>
           [1] => http://foro.elhacker.net/profiles/azielito-u5350.html
           [2] => Azielito
       )

   [88] => Array
       (
           [0] => <a href="http://foro.elhacker.net/multimedia-b3.0/">Multimedia</a>
           [1] => http://foro.elhacker.net/multimedia-b3.0/
           [2] => Multimedia
       )



Saludos.
Mi madre me dijo que estoy destinado a ser pobre toda la vida.
Engineering is the art of balancing the benefits and drawbacks of any approach.