Kullanmak isteyen olur diye paylaşıyorum...
Gereksinim :
simple_html_dom_parser Kütüphanesi.
$url = 'https://anlikaltinfiyatlari.com/';
$user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST,false);
curl_setopt($ch, CURLOPT_POSTFIELDS,false);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$icerik = curl_exec($ch);
curl_close($ch);
require_once 'simple_html_dom.php';
$html = str_get_html($icerik);
// çeyrek Fiyatı //
$cfiyat = $html->find('table.altin',0)->children(3)->children(1)->plaintext;
$cfark = $html->find('table.altin',0)->children(3)->children(2)->plaintext;
$cenyuksek = $html->find('table.altin',0)->children(3)->children(3)->plaintext;
$cendusuk = $html->find('table.altin',0)->children(3)->children(4)->plaintext;
$cenortalam = $html->find('table.altin',0)->children(3)->children(5)->plaintext;
$data['ceyrek'] = [
'ad' => 'ceyrek',
'fiyat'=> $cfiyat,
'fark' => $cfark,
'yuksek' => $cenyuksek,
'dusuk' => $cendusuk,
'ortalama' => $cenortalam
];
// Yarım fiyati //
$yfiyat = $html->find('table.altin',0)->children(4)->children(1)->plaintext;
$yfark = $html->find('table.altin',0)->children(4)->children(2)->plaintext;
$yenyuksek = $html->find('table.altin',0)->children(4)->children(3)->plaintext;
$yendusuk = $html->find('table.altin',0)->children(4)->children(4)->plaintext;
$yenortalam = $html->find('table.altin',0)->children(4)->children(5)->plaintext;
$data['yarim'] = [
'ad' => 'yarim',
'fiyat'=> $yfiyat,
'fark' => $yfark,
'yuksek' => $yenyuksek,
'dusuk' => $yendusuk,
'ortalama' => $yenortalam
];
// Tam fiyati //
$tfiyat = $html->find('table.altin',0)->children(5)->children(1)->plaintext;
$tfark = $html->find('table.altin',0)->children(5)->children(2)->plaintext;
$tenyuksek = $html->find('table.altin',0)->children(5)->children(3)->plaintext;
$tendusuk = $html->find('table.altin',0)->children(5)->children(4)->plaintext;
$tenortalam = $html->find('table.altin',0)->children(5)->children(5)->plaintext;
$data['tam'] = [
'ad' => 'tam',
'fiyat'=> $tfiyat,
'fark' => $tfark,
'yuksek' => $tenyuksek,
'dusuk' => $tendusuk,
'ortalama' => $tenortalam
];
echo json_encode($data);
?>