Micro message public platform (43) train schedule inquiry

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Micro message public platform for the development of micro message public platform development mode of enterprise micro message public platform the train ticket train time interface interface   train trips inquiries
Author: Fang times studio  
text: 


A train, the query interface

Find where the interface in Baidu

http://train.qunar.com/qunar/checiInfo.jsp?ex_track=&q=t110&format=json&cityname=123456&ver=1373813217828&callback=XQScript_5

Q
ver is the current number millisecond time stamp
cityname according to trips inquiries for 123456


Two, the results of data

string(3634) "XQScript_5(
{"ticketInfo":
{"2192\/2193":[
{"pr":88.5,"type":"Hard seat"},
{"pr":183.5,"type":"Hard in"},
{"pr":304.5,"type":"Soft under"}]},"trainInfo":
{"2192\/2193":
{"arriCity_py":"zhengzhou","istmp":false,"code":"2192\/2193","deptCity_py":"wenzhou","arriStation":"Zhengzhou "," arriCity ":" Zhengzhou "," trainType ":" the train "," deptTime ":" 13:52 "," deptStation ":" Wenzhou "," deptCity ":" Wenzhou "," arriTime ":" 14:20 "," interval ":" 1 days 28 hours "}}," trainScheduleHead ": [" times "," name "," date "," time "," drive time "," stop time "," miles "," hard "," soft "," two soft "," a soft seat "," hard sleeper \ / in / "," soft to lie and under"],"extInfo":
{"allMileage":"1496 km "," allTime ":" 1 days 28 hours"},"trainScheduleBody":[
{"mxl":34521376777470,"content":[83,"Changxin south "," the first day "," 23:25 "," 23:29 "," 4 "," 575 kilometers",110,"0","0","0","154\/157\/160","204\/210"]},
{"content":[34,"Wuyi "," the first day "," 17:31 "," 17:33 "," 2 "," 222 kilometers",46.5,"0","0","0","80.5\/83.5\/85.5","107.5\/111.5"]},
{"content":[17,"Lishui "," the first day "," 16:00 "," 16:03 "," 3 "," 136 kilometers",24.5,"0","0","0","58.5\/61.5\/63.5","81.5\/85.5"]},
{"content":[62,""Wuhu," the very next day "," 01:53 "," 02:00 "," 7 "," 753 kilometers",99,"0","0","0","153\/157\/161","217\/224"]},
{"content":[24,""Xuancheng," the very next day "," 00:55 "," 01:03 "," 8 "," 689 kilometers",57,"0","0","0","107\/110\/114","165\/173"]},
{"content":[45,"Deqing Xi "," the first day "," 22:27 "," 22:37 "," 10 "," 517 kilometers",70,"0","0","0","111\/113\/116","156\/161"]},
{"content":[55,"Jinyun "," the first day "," 16:35 "," 16:37 "," 2 "," 168 kilometers",63.5,"0","0","0","97.5\/100.5\/102.5","122.5\/126.5"]},
{"content":[93,"Yongkang "," the first day "," 17:08 "," 17:11 "," 3 "," 201 kilometers",104.5,"0","0","0","138.5\/141.5\/143.5","164.5\/168.5"]},
{"content":[76,"Qingtian "," the first day "," 14:44 "," 14:48 "," 4 "," 57 kilometers",78,"0","0","0","112\/115\/117","131.5\/135.5"]},
{"content":[38,"Wenzhou "," - "," the starting point","13:52","-",0,37,0,0,0,"37\/37\/37","37\/37"]},
{"content":[51,"Hangzhou "," the first day "," 21:30 "," 21:44 "," 14 "," 449 kilometers",73.5,"0","0","0","110.5\/113.5\/115.5","150.5\/155.5"]},
{"mxl":16076029707508,"content":[58,""Bozhou," the very next day "," 10:15 "," 10:22 "," 7 "," 1219 kilometers",114.5,"0","0","0","190.5\/196.5\/202.5","288.5\/300.5"]},
{"mxl":7253046021614,"content":[79,""Huainan," the very next day "," 05:49 "," 05:55 "," 6 "," 989 kilometers",125.5,"0","0","0","191.5\/196.5\/201.5","274.5\/284.5"]},
{"mxl":19294423176992,"content":[69,""Kaifeng," the very next day "," 13:10 "," 13:24 "," 14 "," 1424 kilometers",131.5,"0","0","0","216.5\/223.5\/230.5","328.5\/341.5"]},
{"content":[100,""Chaohu," the very next day "," 02:53 "," 02:59 "," 6 "," 830 kilometers",140,"0","0","0","198\/202\/207","269\/278"]},
{"content":[41,"Hefei "," the very next day "," 03:54 "," 04:14 "," 20 "," 894 kilometers",82,"0","0","0","142\/146\/151","216\/225"]},
{"content":[13,"Yiwu "," the first day "," 19:41 "," 19:46 "," 5 "," 310 kilometers",28.5,"0","0","0","62.5\/65.5\/67.5","93.5\/97.5"]},
{"content":[20,""Fuyang," the very next day "," 07:50 "," 08:20 "," 30 "," 1115 kilometers",71.5,"0","0","0","143.5\/148.5\/154.5","234.5\/245.5"]},
{"content":[96,""Shangqiu," the very next day "," 11:17 "," 11:21 "," 4 "," 1293 kilometers",153.5,"0","0","0","232.5\/238.5\/244.5","333.5\/345.5"]},
{"content":[72,"Jinhua West "," the first day "," 18:52 "," 19:07 "," 15 "," 262 kilometers",85.5,"0","0","0","119.5\/122.5\/124.5","148.5\/152.5"]},
{"content":[31,"Lankao "," the very next day "," 12:29 "," 12:39 "," 10 "," 1381 kilometers",91.5,"0","0","0","174.5\/181.5\/187.5","282.5\/295.5"]},
{"mxl":16683831947510,"content":[107,""Zhengzhou," the very next day "," 14:20 "," station "," - "," 1496 kilometers",170.5,"0","0","0","258.5\/265.5\/272.5","372.5\/386.5"]},
{"mxl":9451012451240,"content":[90,"Civil rights "," the very next day "," 12:04 "," 12:07 "," 3 "," 1345 kilometers",149.5,"0","0","0","230.5\/236.5\/243.5","335.5\/347.5"]}]});"


Three, the source code

<?php
var_dump(getTrainInfo("t110"));

function getTrainInfo($line)
{
    $curTime = explode (" ", microtime());  
    $curMicroTime = round($curTime[1].($curTime[0]*1000));
    $url = "http://train.qunar.com/qunar/checiInfo.jsp?ex_track=&q=".$line."&format=json&cityname=123456&ver=".$curMicroTime."&callback=XQScript_5";

    $headers = array(
        "User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1",
        "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
        "Accept-Language: en-us,en;q=0.5",
        //"Accept-Encoding: gzip, deflate",
        "Referer:  ".$line
    );
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
    $result = curl_exec($ch);
    curl_close($ch);
    
    return $result;
}
?>


Four, legacy

Returns the data are not in order......
need to find another permutation algorithm





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Henry at October 28, 2013 - 5:00 PM