Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/11/2008, 22:13
Suyta
(Desactivado)
 
Fecha de Ingreso: septiembre-2004
Mensajes: 360
Antigüedad: 19 años, 7 meses
Puntos: 1
Cambiar links en página capturada con file_get_contents

Hola todos.

Es posible cambiar los links de las imágenes de Google ?. Lo que quiero es que el link apunte directamente al sitio y no a la biblioteca de Google.
Logré esto, tengo el link que necesito pero ahí estoy trancada

Código PHP:
$full='<a href="/imgres?imgurl=http://www.animalhealthfoundation.com/Images/beloved-horses.jpg&imgrefurl=http://www.animalhealthfoundation.com/about.html&h=600&w=800&sz=57&tbnid=ibidPAhcu4QJ::&tbnh=107&tbnw=143&prev=/images%3Fq%3Dhorses&hl=es&usg=__87z8GeCCkkG1C8l7DjD5Dv9M0LU=&sa=X&oi=image_result&resnum=1&ct=image&cd=1">
<img height="107" width="143" border="1" align="middle" title="http://www.animalhealthfoundation.com/about.html" alt="http://www.animalhealthfoundation.com/about.html" src="http://tbn0.google.com/images?q=tbn:ibidPAhcu4QJ::www.animalhealthfoundation.com/Images/beloved-horses.jpg"/>
</a>'
;

preg_match('/\/imgres([\w\W]*?)\>/',$full,$ftu);
  for (
$az=0$azcount($ftu[0]); $az++) {
    
$deko=$ftu[$az];

preg_match('/imgrefurl([\w\W]*?)h=/',$deko,$ftt2);
  for (
$r=0$rcount($ftt2[0]); $r++) {
  
print_r($ftt2);
  
$d22=$ftt2[$r];
  echo 
$d22;

  
$d22=str_replace("imgrefurl="""$d22);
  
$d22=str_replace("h="""$d22);
  
$d23=preg_replace('|<\/*a.*?>|si'"<a>".$d22."</a>"$full);

  echo 
$d23;

}

Aquí guardo en una variable lo que viene de Google para que puedan ver el código que uso. Sé que ahí estoy eliminando los links que no es lo que necesito.
Alguien sabe cómo puedo hacer ?

Última edición por Suyta; 18/11/2008 a las 22:24