CURL captures vehicle information of Huimin bicycle service point

Source: Internet
Author: User
CURL captures vehicle information of Huimin bicycle service point
  • /* Echo $ aa [FDDMZ]."
    ";
  • Echo "site name:". unescape ($ aa [QCZZZ])."
    ";
  • Echo "total parking space:". $ aa [CWSZZ]."
    ";
  • Echo "available cars:". $ aa [DQCSZ]."
    ";
  • Echo "free parking space:". $ aa [kzcs]."
    ";
  • Echo "Tokyo coordinates:". $ aa [lng]."
    ";
  • Echo "latitude coordinates:". $ aa [lat]."
    ";
  • Echo "address:". unescape ($ aa [addr])."
    ";
  • Echo "============================================== ==========================================
    ";*/
  • }
  • ?>

    1. Vehicle Information of Huimin bicycle service point
  • ";
    CURL captures vehicle information of Huimin bicycle service point

    1. /**
    2. * Huimin bicycle service station 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 Status Code)
    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); // splits the data into arrays.
    31. $ Con = count ($ json_arr );
    32. /**
    33. * Simulate 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) = "&#")
    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. // Print vehicle information cyclically
    63. For ($ I = 0; $ I <$ con; $ I ++)
    64. {
    65. $ Ii = $ I + 1;
    66. $ Aa = json_decode ($ json_arr [$ I], true );
    67. $ Tr1. ="
    $ Ii ". Unescape ($ aa [QCZZZ])." ". $ Aa [CWSZZ]." ". $ Aa [DQCSZ]." ". $ Aa [kzcs]." ". $ Aa [lng]." ". $ Aa [lat]." ". Unescape ($ aa [addr])."
  • No. Site Name Total Parking Space Number of available vehicles Free parking space Longitude coordinate North latitude coordinate Address
  • Related Article

    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.