PHP Grabbing Kurs BCA

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””””

About Administrator

2016-01-12 10:32:36 2016-01-12 14:33:42

Check Also

Create Simple Chat App with Google App Engine Backend and Google Cloud Messaging

Mari membuat aplikasi chat sederhana menggunakan backend Google App Engine (bagian dari Google Cloud Platform) dan …

Tinggalkan Balasan

Translate »
error: Konten dilindungi !!