Curl crawls huimin Bike 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 State code (HTTP status codes)
- Curl_close ($ch);
- $patterns = Array ();
- $patterns [0] = '/' s\d{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 the 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) = = "the")
- {
- Echo substr ($v, 2,-1). "";
- $ar [$k] = Iconv ("UCS-2", "GB2312", Pack ("n", substr ($v, 2,-1)));
- }
- }
- return join ("", $ar);
- }
- Cycle Print vehicle Information
- for ($i =0; $i < $con; $i + +)
- {
- $ii = $i +1;
- $aa =json_decode ($json _arr[$i],true);
- $tr 1.= "
|