Created
November 18, 2012 18:50
-
-
Save unlobito/4106807 to your computer and use it in GitHub Desktop.
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 | |
$url = "http://inposdom.gob.do/codigopostal/jos_codigopostallist.php?start="; | |
$total = 128; | |
$postal = Array(); | |
for ($i=0; $i<=$total; $i++) { | |
$data = file_get_contents($url.($i*2)."1"); | |
preg_match_all('/<tr onmouseover="ew_MouseOver\(event, this\);" onmouseout="ew_MouseOut\(event, this\);" onclick="ew_Click\(event, this\);">(.*?)<\/tr>/s', $data, $areas, PREG_SET_ORDER); | |
foreach ($areas as $area) { | |
preg_match_all('/<div>(.*?)<\/div>/s', $area[1], $aData, PREG_SET_ORDER); | |
$aNombre = mb_convert_case($aData[0][1], MB_CASE_TITLE, "UTF-8"); | |
$aNombre = substr($aNombre, 0, strrpos($aNombre, ',')); | |
echo '"'.$aNombre.'",'; | |
echo '"'.mb_convert_case($aData[1][1], MB_CASE_TITLE, "UTF-8").'",'; | |
echo $aData[2][1]."\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment