Home > Backend Development > PHP Tutorial > CURL captures Huimin bicycle service point vehicle information

CURL captures Huimin bicycle service point vehicle information

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-25 09:02:04
Original
982 people have browsed it
";
  • /*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
    1. Huimin Bicycle Service Point Vehicle Information
    CURL captures Huimin bicycle 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 Status Code (HTTP Status Code)
    16. curl_close($ch);
    17. $patterns = array();
    18. $patterns[0] = '/"sd{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 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. //Loop to print vehicle information
    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]."
  • < /tr>
  • No. Site name Total number of parking spaces
  • Number of available cars Available parking spaces East longitude coordinates North latitude coordinates Address
  • Copy code
    CURL captures Huimin bicycle service point vehicle information


    Previous article:Write files with high concurrency Next article:A super simple and practical HTML parsing class recently collected and written
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Latest Articles by Author
    Latest Issues
    Related Topics
    More>
    Popular Recommendations
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template