Skip to content

Instantly share code, notes, and snippets.

@kamarasta201
Created July 2, 2015 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamarasta201/95c815a0e6ca0885c33f to your computer and use it in GitHub Desktop.
Save kamarasta201/95c815a0e6ca0885c33f to your computer and use it in GitHub Desktop.
grab mudik gratis
public function getMudikgratis()
{
$url = ("http://mudikgratis.dephub.go.id/");
$curl = curl_init($url);
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
$page = curl_exec( $curl );
$d = new DOMDocument();
libxml_use_internal_errors(true);
$d->loadHTML(preg_replace('!\s+!', ' ', str_replace("\xA0", '', $page)));
libxml_use_internal_errors(false);
$xpath = new DOMXPath($d);
$result = array();
$domElement = $xpath->evaluate('//*[@id="laut"]/table')->item(0);
$outerHTML = $domElement->ownerDocument->saveXML($domElement);
return $outerHTML;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment