Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/10/2009, 17:31
Mercader
 
Fecha de Ingreso: abril-2009
Mensajes: 24
Antigüedad: 15 años
Puntos: 0
[Ayuda] Como modificar este Spider

bueno tengo aqui una clase en la que el espider me extrae el cache, pero yo quiero modificarlo para que me extraiga *link, *url , *href... de la web.

Que deveria cambiarle??

Código PHP:
<?
set_time_limit
);
class 
spider_man{    
  var 
$limit;    
  var 
$cache;    
  var 
$crawled;    
  var 
$banned_ext;        
function 
spider_man$url$banned_ext$limit )    
{        
$this->start $url ;        
$this->banned_ext $banned_ext ;        
$this->limit $limit ;                
if( !
fopen$url"r") ) return false;        
else 
$this->_spider$url );    
}
function 
_spider$url ){        
$cache = @file_get_contentsurldecode$url ) );        
if( !
$cache ) return false;        
$this->crawled[] = urldecode$url ) ;
preg_match_all( [COLOR="Red"]"aqui para sacar los H re f[/COLOR]"$cache$links );        
if ( 
$links ) :            
foreach ( 
$links[1] as $hyperlink )            
{                
$this->limit--;                
if( ! 
$this->limit  ) return;
if( 
$this->is_valid_exttrim$hyperlink ) ) and !$this->is_crawled$hyperlink ) ) :                    
$this->crawled[] = $hyperlink;                    
echo 
"Crawling $hyperlink<br />\n";                    
unset( 
$cache );                    
$this->_spider$hyperlink );                
endif;            
}        
endif;    
}    
function 
is_valid_ext$url )    {           
foreach( 
$this->banned_ext as $ext )        {            
if( 
$ext == substr$urlstrlen($url) - strlen$ext ) ) ) return false;        
}        
return 
true;    }    
function 
is_crawled$url ){        
return 
in_array$url$this->crawled );    
  }
}
$banned_ext = array(    
".dtd",    
".css",    
".xml",    
".js",    
".gif",    
".jpg",    
".jpeg",    
".bmp",    
".ico",
".rdf",    
".rss");
$spider = new spider_man([COLOR="Red"]'pagina a extraer link'[/COLOR], $banned_ext100 );
print_r$spider->crawled );
?>
Gracias a todos

Última edición por Mercader; 18/10/2009 a las 17:37