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_USERAGENT, $hc);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$site = curl_exec($ch);
curl_close($ch);
// Veriyi parçalama işlemi
preg_match_all('@(.*?)@si',$site,$veri_derece1);
$ltcfiyat = $veri_derece1[1][0];
return $ltcfiyat;
}
function harun($site1)
{
$ch1 = curl_init();
$hc1 = "YahooSeeker-Testing/v3.9 (compatible; Mozilla 4.0; MSIE 5.5; Yahoo! Search - Web Search)";
curl_setopt($ch1, CURLOPT_REFERER, 'http://www.google.com');
curl_setopt($ch1, CURLOPT_URL, $site1);
curl_setopt($ch1, CURLOPT_USERAGENT, $hc1);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
$site1 = curl_exec($ch1);
curl_close($ch1);
// Veriyi parçalama işlemi
preg_match_all('@(.*?)@si',$site1,$veri_derece2);
$btgfiyat = $veri_derece2[1][0];
return $btgfiyat;
}
$percentage = ($ltcfiyat - $btgfiyat) / $ltcfiyat * 100;
echo round ($percentage, 2);
$giris = siteConnect('https://tr.investing.com/crypto/litecoin/ltc-usd?cid=945630');
$uysal = harun('https://tr.investing.com/crypto/bitcoin-gold/btg-usd');
?>
return dersen degiskenlere sana dondurur fonksiyonlar. bu sekilde dene
echo $giris; //1 ci fonksiyondan donenleri verir.
echo $uysal; // 2ci sonkfiyondan doneneleri verir.