Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/08/2012, 21:19
Avatar de newmesis
newmesis
 
Fecha de Ingreso: octubre-2010
Ubicación: Chillán, Chile, Chile
Mensajes: 42
Antigüedad: 13 años, 7 meses
Puntos: 0
obtener la url de una imagen de otro sitio web

Hola amigos Bueno tengo un problema

consegui este codigo el cual funciona bien

Código PHP:
function getImage($url) { // GET IMDB image
    
try { 
    
$doc = new DOMDocument();
    
$doc->loadHTMLfile_get_contents($url) );
    
$xpath = new DOMXPath($doc);
    return 
$xpath->query('//td[@id="img_primary"]/a/img')->item(0)->getAttribute('src');
    } catch( 
Exception $e ) { return null; }
}
 
echo 
getImage("http://www.imdb.com/title/tt0137523/"); 
el codigo lo entiendo a medias

lo que quiero hacer es mesclarlo con este otro codigo
Código PHP:
/* Todo esto se puede poner en un require :D */    
    
class RssReader 
        var 
$url
        var 
$data
        
        function 
RssReader ($url){ 
            
$this->url
            
$this->data implode (""file ($url)); 
        } 
        
        function 
get_items (){ 
            
preg_match_all ("/<item .*>.*<\/item>/xsmUi"$this->data$matches); 
            
$items = array (); 
            foreach (
$matches[0] as $match){ 
                
$items[] = new RssItem ($match); 
            } 
            return 
$items
        } 
    } 
    
    class 
RssItem 
        var 
$title$url$description
        
        function 
RssItem ($xml){ 
            
$this->populate ($xml); 
        } 
        
        function 
populate ($xml){ 
            
preg_match ("/<title> (.*) <\/title>/xsmUi"$xml$matches); 
            
$this->title $matches[1]; 
            
preg_match ("/<link> (.*) <\/link>/xsmUi"$xml$matches); 
            
$this->url $matches[1]; 
            
preg_match ("/<description> (.*) <\/description>/xsmUi"$xml$matches); 
            
$this->description $matches[1]; 
    } 
        
    function 
get_title (){ 
        return 
iconv('UTF-8''ISO-8859-1'$this->title);
        } 
    
        function 
get_url (){ 
        return 
iconv('UTF-8''ISO-8859-1'$this->url); 
        } 
        
        function 
get_description (){ 
            return 
iconv('UTF-8''ISO-8859-1'$this->description); 
        } 
    } 


//Ejemplo de como usarlo
$rss = new RssReader ("http://www.cinemundo.cl/cines/roble/feed/"); 
    
    foreach (
$rss->get_items () as $item){ 
        
printf ('<div><a href="%s">%s</a><br />%s<br /><br />',
        
html_entity_decode($item->get_url ()),
        
html_entity_decode($item->get_description ()),
        
html_entity_decode($item->get_title ())); 
        
printf ('</div>');
         
 

    } 

el rss contiene lo que quiero la informacion rss de otra web pero no me entrega las imagenes es por eso que quiero mesclarla con el primer codigo