• 26-08-2010, 19:25:24
    #1
    <?php
    
    function adresDownload($Url){
    
    if (!function_exists('curl_init')){
    
    die('CURL yüklü degil!');
    
    }
    
    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, $Url);
    
    curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com/");
    
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729) (Prevx 3.0.5)  ");
    
    curl_setopt($ch, CURLOPT_HEADER, 0);
    
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    
    $cikti = curl_exec($ch);
    
    curl_close($ch);
    
    return $cikti;
    
    }
    
    $site = print adresDownload("http://en.wikipedia.org/w/index.php?title=Aortoiliac_occlusive_disease&printable=yes");
    
    $title = explode('<p> ', $site);
    
    $title = explode('</p>', $title[1]);
    
    ?>
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <?php
    
    echo $title[0];
    
    ?>
    Yanlışım tam olarak nerde?

    Yani ne kadar <p> ... </p> varsa hepsini kopyalamasını, </br> ile alt alta echolamasını istiyorum.
  • 26-08-2010, 21:06:26
    #2
    Bu kod yerine:

    $site = print adresDownload("http://en.wikipedia.org/w/index.php?title=Aortoiliac_occlusive_disease&printable=yes");
    
    $title = explode('<p> ', $site);
    
    $title = explode('</p>', $title[1]);
    Bunu kullanın:

    $site = adresDownload("http://en.wikipedia.org/w/index.php?title=Aortoiliac_occlusive_disease&printable=yes");
    
    preg_match_all('~<p>(.*?)</p>~si', $site, $title);
  • 26-08-2010, 21:16:51
    #3
    Hkan adlı üyeden alıntı: mesajı görüntüle
    Bu kod yerine:

    $site = print adresDownload("http://en.wikipedia.org/w/index.php?title=Aortoiliac_occlusive_disease&printable=yes");
    
    $title = explode('<p> ', $site);
    
    $title = explode('</p>', $title[1]);
    Bunu kullanın:

    $site = adresDownload("http://en.wikipedia.org/w/index.php?title=Aortoiliac_occlusive_disease&printable=yes");
    
    preg_match_all('~<p>(.*?)</p>~si', $site, $title);
    <?php
    
    function adresDownload($Url){
    
    if (!function_exists('curl_init')){
    
    die('CURL yüklü degil!');
    
    }
    
    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, $Url);
    
    curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com/");
    
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729) (Prevx 3.0.5)  ");
    
    curl_setopt($ch, CURLOPT_HEADER, 0);
    
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    
    $cikti = curl_exec($ch);
    
    curl_close($ch);
    
    return $cikti;
    
    }
    
    
    $site = adresDownload("http://en.wikipedia.org/w/index.php?title=Aortoiliac_occlusive_disease&printable=yes");
    
    preg_match_all('~<p>(.*?)</p>~si', $site, $title);
    
    ?>
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <?php
    
    echo $title[0];
    
    ?>
    Cevabın için teşekkürler fakat:

    Array

    olarak dönüyor sayfaya.
  • 26-08-2010, 23:01:19
    #4
    Pardon, onu unutmuşum. $title[0] değişkenini şöyle değiştirin.

    foreach ($title[0] as $t)
    {
      echo $t[1];
    }
    Eğer bununla da istediğiniz sonucu alamazsanız echo '<pre>'; print_r($title); yazın, çıktılara bakın.
  • 26-08-2010, 23:04:11
    #5
    Üyeliği durduruldu
    evet işte her <p> </p> arasını diziye atamış oluyor. Kullanımını $title[0][0], $title[0][1] diye yaparsınız. Sıralamak için de foreach yaparsınız. Öncelikle

    $yenidizi = $title[0] dersiniz.
    sonra da foreach döngüüs yaparsınız.

    foreach($yenidizi as $icerik)
    {
    echo "<br>".$icerik;
    }
    yaparsınız

    edit: Üstteki cevabı görmemiştim özür dilerim