• 01-08-2018, 19:43:06
    #1
    Üyeliği durduruldu
    Merhaba
    Elimde birbirine benzeyen 2 kod yapısı var.
    1.si
    http://nitoz.com/bot/rub.php
    <?php

    function siteConnect($site)
    {

    $ch = curl_init();
    $hc = "YahooSeeker-Testing/v3.9 (compatible; Mozilla 4.0; MSIE 5.5; Yahoo! Search - Web Search)";
    curl_setopt($ch, CURLOPT_REFERER, 'http://www.google.com');
    curl_setopt($ch, CURLOPT_URL, $site);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_USERAGENT, $hc);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $site = curl_exec($ch);
    curl_close($ch);


    // Veriyi parçalama işlemi
    preg_match_all('@<span class="arial_26 inlineblock pid-2186-last" id="last_last" dir="ltr">(.*?)</span>@si',$site,$ruble);




    echo "Usd TO Ruble: ".$ruble[1][0]."<br />";


    }

    $giris = siteConnect('https://tr.investing.com/currencies/usd-rub');

    ?>
    2.si
    http://nitoz.com/bot/al.php
    <?php

    function siteConnect($site)
    {

    $ch = curl_init();
    $hc = "YahooSeeker-Testing/v3.9 (compatible; Mozilla 4.0; MSIE 5.5; Yahoo! Search - Web Search)";
    curl_setopt($ch, CURLOPT_REFERER, 'http://www.google.com');
    curl_setopt($ch, CURLOPT_URL, $site);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_USERAGENT, $hc);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $site = curl_exec($ch);
    curl_close($ch);


    // Veriyi parçalama işlemi
    preg_match_all('@<span class="arial_26 inlineblock pid-49768-last" id="last_last" dir="ltr">(.*?)</span>@si',$site,$ruble);




    echo "Aliminyum: ".$ruble[1][0]."<br />";


    }

    $giris = siteConnect('https://tr.investing.com/commodities/aluminum-historical-data');

    ?>
    Bunları tek tek açtığımda sonuçları veriyor ancak tek bir sayfada göstermek istediğimde php hatası veriyor.
    İnculude once ile sadece bir değeri veriyor.


    http://nitoz.com/bot/pat.php
    <?php
    include_once "rub.php";
    include_once "al.php";
    ?>
    beni istediğim 2 sonucuda tek bir sayfada birleştirmek. bunu nasıl yapabilirim?[COLOR="Silver"]
  • 02-08-2018, 00:04:53
    #2
    Kurumsal Üye
    https://hastebin.com/ludokizige.xml

    buyrun, bu yardımcı olacaktır.
  • 02-08-2018, 17:05:07
    #3
    <?php
    
    function siteConnect($site,$id)
    {
    
    $ch = curl_init();
    $hc = "YahooSeeker-Testing/v3.9 (compatible; Mozilla 4.0; MSIE 5.5; Yahoo! Search - Web Search)";
    curl_setopt($ch, CURLOPT_REFERER, 'http://www.google.com');
    curl_setopt($ch, CURLOPT_URL, $site);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_USERAGENT, $hc);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $site = curl_exec($ch);
    curl_close($ch);
    
    
    // Veriyi parçalama işlemi
    preg_match_all('@<span class="arial_26 inlineblock pid-'.$id.'-last" id="last_last" dir="ltr">(.*?)</span>@si',$site,$data);
    return $data[1][0];
    
    }
    
    $ruble = siteConnect('https://tr.investing.com/currencies/usd-rub',2186);
    $Aliminyum = siteConnect('https://tr.investing.com/commodities/aluminum-historical-data',49768);
    
    echo "Usd TO Ruble: ".$ruble."<br />";
    echo "Aliminyum: ".$Aliminyum."<br />";