Last active
December 19, 2015 04:39
-
-
Save arifwidip/5898837 to your computer and use it in GitHub Desktop.
Get Exchange Rates From Bank Indonesia using WordPress HTTP API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$kurs_page = wp_remote_get( 'http://www.bi.go.id/id/moneter/informasi-kurs/transaksi-bi/', array( 'timeout' => 20 ) ); | |
if( !is_wp_error( $kurs_page) ) { | |
$result = $kurs_page['body']; | |
$data_table = explode('<div id="right-cell">', $result); | |
$data_table = explode ('<table class="table1" cellspacing="0" rules="all" border="1" id="ctl00_PlaceHolderMain_biWebKursTransaksiBI_GridView1">',$data_table[1]); | |
$data_table = explode ('</table>', $data_table[1]); | |
$dom = new DOMDocument(); | |
$html = $data_table[0]; | |
@$dom->loadHTML( $html ); | |
$rows = $dom->getElementsByTagName('tr'); | |
$counter = 0; | |
// Loop each rows | |
foreach( $rows as $row ) { | |
if( !empty( $row->nodeValue ) ) { | |
// Loop each columns | |
foreach( $row->childNodes as $column ) { | |
if ( !empty($column->nodeValue) ) { | |
$data_kurs[$counter][] = $column->nodeValue; | |
} | |
} | |
$counter++; | |
} | |
} | |
} | |
?> |
Ok thank you, i have revise the code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Revision for line 2-7 with new Bank Indonesia Website Design