Mencoba Teknik Curl Php

Unknown Reply 12:10 PM

<?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 "<div align='left'><strong>Data Kurs</strong></div>";
echo "<hr>";
echo "<table width='30px' border='0' cellpadding='5'
class='kosong'>";
echo "<tr class='head'><td align='center' width=10px>KURS
</td><td width=10px>JUAL</td><td width=10px>BELI</
td></tr>";
echo $pecahLagi[0];
echo "</table>";
echo "<hr>";
$html = preg_replace('/<td.*?>(.*?)<\/td>/i',
'$1',str_replace(" ","",$pecahLagi[0]));
$dummy=str_replace("\n\r","|",str_replace("<tr>",'',str_repl
ace("</tr>",'',$html)));
$kurs=explode("||",$dummy);
$data='';
foreach($kurs as $k){
$d=explode("\n\r",str_replace("|","",$k));
$data.=trim(str_replace("\n","|",$d[0]));
}
$hasil=explode('|',$data);
?>
<form id="form1" name="form1" method="post" action="">
<?php
$num=count($hasil)-1;
for($i=1;$i<$num;$i++){
echo "<input type='text' name='textfield$i' id='textfield$i'
value='$hasil[$i]' />".($i%3==0?'<br/>':'');
}
?>
</form>
?>

Related Posts

PHP 4177791850316668968
Comments
0 Comments
Facebook Comments by Media Blogger

Post a Comment

Search

Ikuti Channel Youtube Aku Yaa.. Jangan Lupa di subscribe. Terima kasih.

Popular Posts

Translate