Created
May 15, 2013 05:41
-
-
Save ruliarmando/5581858 to your computer and use it in GitHub Desktop.
scrapping bmkg website with curl + simplehtmldom
This file contains 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 | |
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