Assalamualaikum Warrahmatullah Wabarakatuh

Apa Kabar semua, salam iso..

Berikut ane mau share script pusaka untuk tampilkan kurs dari bca

Langsung aja yach

 

<?php  

function bacaHTML($url){  

     // inisialisasi CURL  

     $data = curl_init();  

     // setting CURL  

     curl_setopt($data, CURLOPT_RETURNTRANSFER, 1);  

     curl_setopt($data, CURLOPT_URL, $url);  

     // menjalankan CURL untuk membaca isi file  

     $hasil = curl_exec($data);  

     curl_close($data);  

     return $hasil;  

}  

$kodeHTML =  bacaHTML('http://www.klikbca.com');  

$pecah = explode('<table width="139" border="0" cellspacing="0" cellpadding="0">', $kodeHTML);  

$pecahLagi = explode('</table>', $pecah[2]);  

echo "<table border='1'>";  

echo "<tr><td>KURS</td><td>JUAL</td><td>BELI</td></tr>";  

echo $pecahLagi[0];  

echo "</table>";  

?>

 

Dan ini yang satunya, jadi agan tinggal pilih deh..

 

<? 

$url = "http://www.klikbca.com/corporate/Ind/rates.html" ; 

$html_start = '<table border="0" cellspacing="0" cellpadding="0">'; 

$html_end = '<!--- Mulai proses ----->'; 

ini_set ('allow_url_fopen', '1' ); 

ini_set ('auto_detect_line_endings', 'Off') ; 

ini_set ('default_socket_timeout', '60' ); 

ini_set ('max_execution_time', '0' ); 

flush() ; 

$f = fopen ($url, 'r' ); 

$doc = ''; 

while (! feof ($f) ) { 

$doc = $doc . fgets($f, 3072) ; 

fclose ($f) ; 

if ($doc != '') { 

$a = strpos($doc, $html_start) ; 

$b = strpos($doc, $html_end) - $a ; 

$show = substr($doc, $a, $b) ; 

$show = ereg_replace($html_start, '<table border=0 cellspacing=0 cellpanding=0 width=100%>', $show) ; 

$show = ereg_replace("bgcolor=\"#6699CC\"", "", $show) ; 

$show = ereg_replace("bgcolor=\"#ff9c00\"", "", $show) ; 

$show = ereg_replace("white", "#000000", $show) ; 

$show = ereg_replace("bgcolor='#e0e0e0'", "", $show) ; 

$show = ereg_replace("\"#0000a0\"", "#000000", $show) ; 

$show = ereg_replace("<font color=\"#000000\" size=\"2\" face=\"Verdana\">", "<font face=\"Verdana\" style=\"font-size: 8pt\">", $show) ; 

$show = ereg_replace("<font face=\"Arial\" size=\"2\" color=#000000>", "<font face=\"Verdana\" style=\"font-size: 8pt\">", $show) ; 

$show = ereg_replace("<strong>DD/TT</strong>", "", $show) ; 

$show = ereg_replace("Mata Uang", "Duit", $show) ; 

$show = ereg_replace("<strong>Duit</strong>", "Kurs", $show) ; 

$show = ereg_replace("<strong>Jual</strong>", "Jual", $show) ; 

$show = ereg_replace("<strong>Beli</strong>", "Beli", $show) ; 

$show = ereg_replace("<br>", "", $show) ; 

$show = ereg_replace(" ", "", $show) ; 

$show = ereg_replace("</font> </td>", "", $show) ; 

$show = ereg_replace("</table> 

<td>", "</table>", $show) ; 

print "$show" ; 

flush() ; 

?>

 

Sekian artikel dari ane. Terima kasih gan^_^