CURL captures Huimin bicycle service point vehicle information
- /**
- * Huimin Bicycle Service Point Vehicle Information
- * @Support: QQ 910111100 (JoY)
- * @Time: 2012.09.29 15:50:00
- * @HZapi.com (http://www.hzapi.com/)
- */
- $url = "http://www.2773456.com/zdfb/huizhou_station.php";
- $ch = curl_init();
- curl_setopt ($ch, CURLOPT_URL, $url);
- curl_setopt ($ch, CURLOPT_REFERER, 'http://www.2773456.com/zdfb/');
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt ($ch , CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
- curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
- $json = curl_exec($ch);
- //curl_getinfo($ch ,CURLINFO_HTTP_CODE); //HTTP Status Code (HTTP Status Code)
- curl_close($ch);
- $patterns = array();
- $patterns[0] = '/"sd{1,3}":/' ;
- $patterns[1] = '/var area = {/';
- $patterns[2] = '/}}/';
- $patterns[3] = '/},/';
- $patterns[4 ] = '/Su/';
- $find = array();
- $find[0] = "";
- $find[1] = "";
- $find[2] = "}";
- $ find[3] = "}#";
- $find[4] = "%u";
- $json = preg_replace($patterns, $find, $json); //Filter extra characters
- $json_arr=explode( '#',$json); //Split into arrays
- $con=count($json_arr);
- /**
- * Simulate unescape in JS
- *
- * @Support: QQ 910111100 (JoY)
- * @Time: 2012.09.29 15:50:00
- * @HZapi.com (http://www.hzapi.com/)
- */
- //echo unescape('%u4e1c%u6e56%u82b1%u56ed4%u53f7 %u5c0f%u533a');
- function unescape($str) {
- $str = rawurldecode($str);
- preg_match_all("/(?:%u.{4})|.{4};|d+ ;|.+/U",$str,$r);
- $ar = $r[0];
- #print_r($ar);
- foreach($ar as $k=>$v) {
- if (substr($v,0,2) == "%u")
- {
- $ar[$k] = iconv("UCS-2","GB2312//IGNORE",pack("H4",substr( $v,-4)));
- }
- elseif(substr($v,0,3) == "")
- {
- $ar[$k] = iconv("UCS-2","GB2312", pack("H4",substr($v,3,-1)));
- }
- elseif(substr($v,0,2) == "")
- {
- echo substr($v,2 ,-1)."";
- $ar[$k] = iconv("UCS-2","GB2312",pack("n",substr($v,2,-1)));
- }
- }
- return join("",$ar);
- }
-
- //Loop to print vehicle information
- for($i=0;$i<$con;$i++)
- {
- $ii=$i+1;
- $aa=json_decode($json_arr[$i],true);
- $tr1.="
$ii | ".unescape($aa[QCZZZ]) ." | ".$aa[CWSZZ]." | ".$aa[DQCSZ]." | ".$ aa[kzcs]." | ".$aa[lng]." | ".$aa[lat]." | | ";
- /*echo $aa[FDDMZ]."
";
- echo "Site Name:". unescape($aa[QCZZZ])."
";
- echo "Total number of parking spaces:".$aa[CWSZZ]."
";
- echo "Number of cars available to borrow:".$aa[ DQCSZ]."
";
- echo "Vacant parking spaces:".$aa[kzcs]."
";
- echo "Tokyo coordinates:".$aa[lng]."
";
- echo "North latitude coordinates:".$aa[lat]."
";
- echo "Address:".unescape($aa[addr])."
";
- echo "= ================================================== =======================
";*/
- }
- ?>
Copy code
-
- Huimin Bicycle Service Point Vehicle Information
-
-
-
Copy code
|