Advertisements
Grabbing kurs BCA (PHP)

Grabbing kurs BCA (PHP)

Script untuk menampilkan kurs mata uang dari BCA (klikBCA.com) dalam PHP, copy script berikut, simpan dengan nama bca.php (terserah anda). Jangan lupa untuk menampilkan sumbernya (BCA)

berikut script lengkapnya, silakan dicoba…

<?php
$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() ;
?>
Advertisements
2

6 Responses

  1. handoyo
    13/07/2010
    • andykamto
      16/07/2010
  2. kardjo
    05/12/2011
  3. Rafly
    18/02/2012
  4. muhammad hafid
    25/06/2012
  5. mas ihsan blog
    29/07/2012

Kirim Komentar