• 30-01-2013, 10:21:37
    #1
    Aşağıda verdiğim kodlarda problem yaşıyorum. Daha doğrusu bu kodları bir site üzerinde kullanabilirken başka bir site üzerinden veri alamıyorum. Kodları veriyi çekmek istediğim sitenin kaynak koduna göre düzenledim. Ama herhangi bir veri alamıyorum. Bu konuda yardımcı olabilir misiniz?

    function get($first, $last, $text)
    {
        @preg_match_all('/' . preg_quote($first, '/') .
            '(.*?)'. preg_quote($last, '/').'/i', $text, $m);
        return @$m[1];
    }
    // Save to Product
    if (isset($_POST["save"])) {
        $url        = mysql_real_escape_string($_POST["url"]);
        $content    = file_get_contents($url);
        $get_title  = get('class="page-main-title product-model-name"><span>', '</span></h1>', $content);
        $get_text   = get('class="tab-inner-content overview cf">', '</div>', $content);
        $get_pic    = get(preg_match( '/class="detail-link gallery-link fancybox.iframe"><img src="([^"]*)"/i', $content, $out)) ;
        $get_thumb  = get(preg_match( '/class="detail-link gallery-link fancybox.iframe"><img src="([^"]*)"/i', $content, $out)) ;
        $setlang    = mysql_real_escape_string($_POST["setlang"]);
        $catid		= mysql_real_escape_string($_POST["catid"]);
        $title      = mysql_real_escape_string($get_title[0]);
        $text       = mysql_real_escape_string($get_text[0]);
        $pic        = mysql_real_escape_string($out[1]);
        $thumb      = mysql_real_escape_string($out[1]);
        $site       = mysql_real_escape_string($_POST["site"]);
        $add = mysql_query("insert into products (pic, thumb, setlang, catid, title, property, site) values ('$pic', '$thumb', '$setlang', '$catid', '$title', '$text', '$site')");
        if($add){
            header("Location: message.php?read=apply");
        }else{
            header("Location: message.php?read=error");
        }
    }
    Ürünü çekmek istediğim sayfa linkini yardımcı olmak isteyenlere ö.m yoluyla gönderebilirim.
  • 31-01-2013, 00:21:02
    #2
    pm atarmısın yada buraya yaz bakalım
  • 31-01-2013, 00:34:49
    #3
    Üyeliği durduruldu
    Merhaba, / işaretlerini regex fonksiyonlarda kullanırken \/ olarak kullanılması yani önüne ters slash koyulması gerekli. Çünkü bitiş tagi olarak algılanıyor, sonrasında yazı gelince uçuyor.
  • 31-01-2013, 10:07:40
    #4
    <?php
    set_time_limit(0);
    function baglan($feed,$coo=null,$ref=null){
    
    	$ch = curl_init(); 
    	$timeout = 0;
    	curl_setopt($ch,CURLOPT_URL,$feed);
    	curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
    	curl_setopt($ch,CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
    	
    	if(!empty($coo)){  
    		curl_setopt($ch,CURLOPT_COOKIEFILE,$coo); 
    		curl_setopt($ch,CURLOPT_COOKIEJAR,$coo);
    	}
    	
    	if(empty($ref)){
    	
    		curl_setopt($ch,CURLOPT_REFERER,$feed);
    	
    	}else{
    	
    		curl_setopt($ch,CURLOPT_REFERER,$ref);
    	} 
    	curl_setopt ($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    	$veri= curl_exec($ch);
    	curl_close($ch);
    	return $veri;
    
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <?php
    $site  = baglan("http://www.sony.co.uk/pro/product/hc3d/pmw-10md/overview");
    
    $title = explode('<title>',$site);
    $title = explode('</title>',$title[1]);
    $title = $title[0];
    
    $desc  = explode('<META NAME="description" CONTENT="',$site);
    $desc  = explode('"',$desc[1]);
    $desc  = $desc[0];
    
    $over  = explode('<div class="tab-inner-content overview cf">',$site);
    $over  = explode('</div>',$over[1]);
    $over  = $over[0];
    
    
    preg_match_all('#<a href="http://sp.sony-europe.com/da/(.*?)" class="thumbnail">#si',$site,$img);
    
    echo $title."<br>";
    echo $desc."<br>";
    echo $over."<br>";
    
    	for($i=0; $i<count($img[1]); $i++){
    		echo "http://sp.sony-europe.com/da/".$img[1][$i]."<br>";
    	}
    ?>
    </body>
    </html>
    bu örnek işini görür kolay gelsin
  • 31-01-2013, 10:26:39
    #5
    SefaCan adlı üyeden alıntı: mesajı görüntüle
    <?php
    set_time_limit(0);
    function baglan($feed,$coo=null,$ref=null){
    
    	$ch = curl_init(); 
    	$timeout = 0;
    	curl_setopt($ch,CURLOPT_URL,$feed);
    	curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
    	curl_setopt($ch,CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
    	
    	if(!empty($coo)){  
    		curl_setopt($ch,CURLOPT_COOKIEFILE,$coo); 
    		curl_setopt($ch,CURLOPT_COOKIEJAR,$coo);
    	}
    	
    	if(empty($ref)){
    	
    		curl_setopt($ch,CURLOPT_REFERER,$feed);
    	
    	}else{
    	
    		curl_setopt($ch,CURLOPT_REFERER,$ref);
    	} 
    	curl_setopt ($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    	$veri= curl_exec($ch);
    	curl_close($ch);
    	return $veri;
    
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <?php
    $site  = baglan("http://www.sony.co.uk/pro/product/hc3d/pmw-10md/overview");
    
    $title = explode('<title>',$site);
    $title = explode('</title>',$title[1]);
    $title = $title[0];
    
    $desc  = explode('<META NAME="description" CONTENT="',$site);
    $desc  = explode('"',$desc[1]);
    $desc  = $desc[0];
    
    $over  = explode('<div class="tab-inner-content overview cf">',$site);
    $over  = explode('</div>',$over[1]);
    $over  = $over[0];
    
    
    preg_match_all('#<a href="http://sp.sony-europe.com/da/(.*?)" class="thumbnail">#si',$site,$img);
    
    echo $title."<br>";
    echo $desc."<br>";
    echo $over."<br>";
    
    	for($i=0; $i<count($img[1]); $i++){
    		echo "http://sp.sony-europe.com/da/".$img[1][$i]."<br>";
    	}
    ?>
    </body>
    </html>
    bu örnek işini görür kolay gelsin
    Teşekkürler. Allah razı olsun.