Curl crawls huimin Bike Service point vehicle information

Source: Internet
Author: User
  • /*echo $aa [FDDMZ]. "
    ";
  • ";
  • echo "Site name:". unescape ($aa [qczzz]). "
    ";
  • echo "Total number of parking spaces:". $aa [Cwszz]. "
    ";
  • echo "Number of available vehicles:" $aa [Dqcsz]. "
    ";
  • echo "Free Parking:" $aa [Kzcs]. "
    ";
  • echo "Tokyo coordinates:". $AA [LNG].
    ";
  • echo "Latitude coordinates:". $AA [lat]. "
    ";
  • echo "Address:". unescape ($aa [addr]). "
    ";
  • echo "==========================================================================
    ";*/
  • }
  • ?> Copy Code
    1. Huimin Bicycle Service Point vehicle information
  • Curl crawls huimin Bike Service point vehicle information
    1. /**
    2. * Huimin Bicycle Service point vehicle information
    3. * @Support: QQ 910111100 (JoY)
    4. * @Time: 2012.09.29 15:50:00
    5. * @HZapi. COM (http://www.hzapi.com/)
    6. */
    7. $url = "http://www.2773456.com/zdfb/huizhou_station.php";
    8. $ch = Curl_init ();
    9. curl_setopt ($ch, Curlopt_url, $url);
    10. curl_setopt ($ch, Curlopt_referer, ' http://www.2773456.com/zdfb/');
    11. curl_setopt ($ch, Curlopt_returntransfer, 1);
    12. curl_setopt ($ch, Curlopt_useragent, "mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ");
    13. curl_setopt ($ch, curlopt_connecttimeout,10);
    14. $json = curl_exec ($ch);
    15. Curl_getinfo ($ch, Curlinfo_http_code); HTTP State code (HTTP status codes)
    16. Curl_close ($ch);
    17. $patterns = Array ();
    18. $patterns [0] = '/' s\d{1,3} ':/';
    19. $patterns [1] = '/var area = {/';
    20. $patterns [2] = '/}}/';
    21. $patterns [3] = '/},/';
    22. $patterns [4] = '/\su/';
    23. $find = Array ();
    24. $find [0] = "";
    25. $find [1] = "";
    26. $find [2] = "}";
    27. $find [3] = "}#";
    28. $find [4] = "%u";
    29. $json = Preg_replace ($patterns, $find, $json); Filter extra characters
    30. $json _arr=explode (' # ', $json); Split into arrays
    31. $con =count ($json _arr);
    32. /**
    33. * Simulate the unescape in JS
    34. *
    35. * @Support: QQ 910111100 (JoY)
    36. * @Time: 2012.09.29 15:50:00
    37. * @HZapi. COM (http://www.hzapi.com/)
    38. */
    39. echo unescape ('%u4e1c%u6e56%u82b1%u56ed4%u53f7%u5c0f%u533a ');
    40. function Unescape ($STR) {
    41. $str = Rawurldecode ($STR);
    42. Preg_match_all ("/(?:%u.{4}) |. {4};|&#\d+;|.+/u ", $str, $r);
    43. $ar = $r [0];
    44. #print_r ($ar);
    45. foreach ($ar as $k = = $v) {
    46. if (substr ($v, 0,2) = = "%u")
    47. {
    48. $ar [$k] = Iconv ("UCS-2", "Gb2312//ignore", Pack ("H4", substr ($v,-4)));
    49. }
    50. ElseIf (substr ($v, 0, 3) = = "")
    51. {
    52. $ar [$k] = Iconv ("UCS-2", "GB2312", Pack ("H4", substr ($v, 3,-1)));
    53. }
    54. ElseIf (substr ($v, 0,2) = = "the")
    55. {
    56. Echo substr ($v, 2,-1). "";
    57. $ar [$k] = Iconv ("UCS-2", "GB2312", Pack ("n", substr ($v, 2,-1)));
    58. }
    59. }
    60. return join ("", $ar);
    61. }
    62. Cycle Print vehicle Information
    63. for ($i =0; $i < $con; $i + +)
    64. {
    65. $ii = $i +1;
    66. $aa =json_decode ($json _arr[$i],true);
    67. $tr 1.= "
    $ii ". Unescape ($aa [qczzz])." ". $aa [Cwszz]." ". $aa [Dqcsz]." ". $aa [Kzcs]." ". $aa [LNG]." ". $aa [lat]." ". unescape ($aa [addr])."
  • Number Site name Total number of parking spaces Number of vehicles to borrow Free parking Space Longitude coordinates Latitude coordinates Address
  • Copy Code
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.