• 17-06-2013, 01:49:19
    #1
    İki farklı sitede tek dosyada curl komutlarını çalıştırmam gerekiyor. Ancak bir site utf-8 diğeri ise iso-8859-9 ikisinden de aynı dosya içinde curl ile içerik çekliyor.
    function curl_cek($url){
        $baslig[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
        $baslig[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
        $baslig[] = "Cache-Control: max-age=0";
        $baslig[] = "Connection: keep-alive";
        $baslig[] = "Keep-Alive: 300";
        $baslig[] = "Accept-Charset: ISO-8859-9,utf-8;q=0.7,*;q=0.7";
        $baslig[] = "Accept-Language: en-us,en;q=0.5";
        $baslig[] = "Pragma: ";
        $useragent = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)';
        $ch = curl_init();
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($ch, CURLOPT_REFERER, $url);
        curl_setopt ($ch, CURLOPT_USERAGENT, $useragent);
    	curl_setopt ($ch, CURLOPT_HTTPHEADER, $baslig);
        curl_setopt ($ch, CURLOPT_TIMEOUT , 30);
        $rmx = curl_exec($ch);	
    	$rmx = mb_convert_encoding ($rmx, "auto");
    /*//bu şekilde de denedim yine olmadı.
    $contentType = curl_getinfo($rmx, CURLINFO_CONTENT_TYPE);
        if($contentType == "iso-8859-9"){
    	$rmx = mb_convert_encoding ($rmx, "iso-8859-9", "utf-8");
    	}
    	elseif($contentType == "utf-8"){
    	$rmx = mb_convert_encoding ($rmx, "utf-8", "iso-8859-9");
    	}
    //*/
    	curl_close($ch);
        return $rmx;
    }
  • 17-06-2013, 03:09:26
    #2
    Üyeliği durduruldu
    iconv Kullan
  • 17-06-2013, 12:51:05
    #3
    madly0011 adlı üyeden alıntı: mesajı görüntüle
    iconv Kullan
    iconv de de aynı şekilde oluyor birini düzeltirken diğer karakter setine sahip olan sitede hata oluyor. küçük bir fonk. yazılması gerekiyor ama ne bilmiyorum. php bilgim o kadar iyi değil.
  • 17-06-2013, 13:50:04
    #4
    kendi sayfanın karakter seti ne ?
  • 17-06-2013, 14:26:33
    #5
    husee3 adlı üyeden alıntı: mesajı görüntüle
    kendi sayfanın karakter seti ne ?
    index.php dosyasına
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    ve
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
    ikisinide denedim aynı şekilnde ayarlar.php yani curl komutlarının yer aldığı dosyaya da
    <?php
    header("Content-Type: text/html; charset=UTF-8");
    ?>
    ve iso-8859-9 karakter setini de denedim ama biri düzelirken öteki bozuluyor.
  • 17-06-2013, 14:35:59
    #6
    ufukt51 adlı üyeden alıntı: mesajı görüntüle
    index.php dosyasına
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    ve
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
    ikisinide denedim aynı şekilnde ayarlar.php yani curl komutlarının yer aldığı dosyaya da
    <?php
    header("Content-Type: text/html; charset=UTF-8");
    ?>
    ve iso-8859-9 karakter setini de denedim ama biri düzelirken öteki bozuluyor.
    php karakter seti -> utf-8
    html karakter seti -> utf-8
    Php sayfa yapısı -> utf-8
    1. site ( utf 8 olan ) direk curl ile çek
    2. site iso*8859-9 olan Curl ile çek iconv ile gelenveriyi utf-8 yap

    Mantık bu birisi farklı birisi farklı olmaycak hepsi utf-8 gelmek zorunda
  • 17-06-2013, 15:16:07
    #7
    Big_turk halletti saolsun
    function curl_cek($url){
         $useragent = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)';
        $ch = curl_init();
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($ch, CURLOPT_REFERER, $url);
        curl_setopt ($ch, CURLOPT_USERAGENT, $useragent);
        curl_setopt ($ch, CURLOPT_HTTPHEADER, $baslig);
        curl_setopt ($ch, CURLOPT_TIMEOUT , 30);
        $rmx = curl_exec($ch);    
         curl_close($ch);
        return $rmx;
    }
    fonksiyonunu
     $bir = curl_cek('http://www.site.com/');
    		$bir = mb_convert_encoding ($bir, "utf-8", "iso-8859-9");
    şeklinde ayrı ayrı sitelere uyguladım ve hallettim teşekkürler yardımlarınız için.
  • 07-10-2020, 00:01:49
    #8
    ufukt51 adlı üyeden alıntı: mesajı görüntüle
    Big_turk halletti saolsun
    function curl_cek($url){
         $useragent = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)';
        $ch = curl_init();
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($ch, CURLOPT_REFERER, $url);
        curl_setopt ($ch, CURLOPT_USERAGENT, $useragent);
        curl_setopt ($ch, CURLOPT_HTTPHEADER, $baslig);
        curl_setopt ($ch, CURLOPT_TIMEOUT , 30);
        $rmx = curl_exec($ch);    
         curl_close($ch);
        return $rmx;
    }
    fonksiyonunu
     $bir = curl_cek('http://www.site.com/');
            $bir = mb_convert_encoding ($bir, "utf-8", "iso-8859-9");
    şeklinde ayrı ayrı sitelere uyguladım ve hallettim teşekkürler yardımlarınız için.
    Seneler sonra konuyu hortlatayım. Böyle bir sorun alıyordum. Dediğiniz işlemleri yaptım sorunum çözüldü teşekkürler hocam.