Skip to content

Instantly share code, notes, and snippets.

@ruliarmando
Created May 15, 2013 05:41
Show Gist options
  • Save ruliarmando/5581858 to your computer and use it in GitHub Desktop.
Save ruliarmando/5581858 to your computer and use it in GitHub Desktop.
scrapping bmkg website with curl + simplehtmldom
<?php
include 'simple_html_dom.php';
$cookie_jar = tempnam('/tmp', 'cookie');
$c = curl_init('http://www.bmkg.go.id/BMKG_Pusat/Meteorologi/Prakiraan_Cuaca_Indonesia.bmkg');
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_jar);
$page = curl_exec($c);
curl_close($c);
$html = str_get_html($page);
$content = $html->find('#content');
foreach($content as $c){
$table = $c->find('table', 0);
}
//table prakiraan cuaca
echo $table;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment